Ruby on Rails Thursday, September 2, 2010

On 2 September 2010 21:49, Robert Walker <lists@ruby-forum.com> wrote:
> Bill Walton wrote:
>>  In addition to Chris' recommendations, you should check out the Rails
>> ActiveSupport::CoreExtensions helpers like .beginning_of_day and
>> .end_of_day methods which, IMHO, are more readable than using
>> :advance.
>
> It's also possible to improve readability using more Ruby like idioms:
>
> @items = Item.find(:all, :conditions => {:created_at =>
> Date.today...Date.today + 1.day } )
>
> SELECT * FROM "items" WHERE ("items"."created_at" >= '2010-09-02' AND
> 'items"."created_at" < '2010-09-03')

But going back to the OP's original point, that will give all items
created on that day UTC whereas I think he wanted items created today
local time.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment