# Datebocks formatting

**URL:** <https://discuss.rubyonrails.org/t/datebocks-formatting/5855>\
**Category:** rubyonrails-talk\
**Created:** [December 14, 2006, 5:14pm UTC](https://discuss.rubyonrails.org/t/datebocks-formatting/5855 "2006-12-14T17:14:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eduardo\_Yanez\_Parare](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@Eduardo\_Yanez\_Parare](https://discuss.rubyonrails.org/u/Eduardo_Yanez_Parare)\
**Post date:** [December 14, 2006, 5:14pm UTC](https://discuss.rubyonrails.org/t/datebocks-formatting/5855/1 "2006-12-14T17:14:12Z")

</div>

Hello, I've started using datebocks yesterday, it seems amazing to me, but I have some problems I can't solve. When I show a model's date I do:

\<%= datebocks\_field('backup', 'bkdate') %\>

But the field in the database is a datetime so datebocks show me a date as

2001/01/24 00:00:00

and I don't want to see the time, only the date. How do I tell datebocks to use another format?

---

<div class="post-metadata">

**Author:** ![Eduardo\_Yanez\_Parare](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@Eduardo\_Yanez\_Parare](https://discuss.rubyonrails.org/u/Eduardo_Yanez_Parare)\
**Post date:** [December 14, 2006, 5:36pm UTC](https://discuss.rubyonrails.org/t/datebocks-formatting/5855/2 "2006-12-14T17:36:40Z")

</div>

Morover I've seen a bug:

When you show a date field with datebocks:

\<%= datebocks\_field('backup', 'bkdate') %\>

it shows you the date in format: 2002/11/08 00:00:00. But that's what I said in my first post. The bug heppens when you delete the triling time and lost the focus, then it change the date to yyyy-mm-dd but it changes the value to 2008-02-11!!!!!!!

---

<div class="post-metadata">

**Author:** ![Eduardo\_Yanez\_Parare](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@Eduardo\_Yanez\_Parare](https://discuss.rubyonrails.org/u/Eduardo_Yanez_Parare)\
**Post date:** [December 15, 2006, 10:04am UTC](https://discuss.rubyonrails.org/t/datebocks-formatting/5855/3 "2006-12-15T10:04:11Z")

</div>

Well, I've solved this situation. My model has an attribute named bkdate, yes, I know it's a bit strange but it's a legacy system I'm making with Rails. Then I have added two methods in the model:

# To show the date in the right format def date &nbsp;&nbsp;&nbsp;return bkdate.strftime("%Y-%m-%d") end

# This method does nothing but the framework asks for it. def date=(value) &nbsp;&nbsp;&nbsp;bkdate = value end

In the view I've used date instead of bkdate:

\<td\>\<%= datebocks\_field('backup', 'date') %\>\</td\>

And finally in the controller's update method I added this line:

params[:backup][:bkdate] = params[:backup][:date]

to assign the date's value to bkdate in params hash

And that's all, it works! 🙂
