On Apr 27, 2010, at 4:24 PM, Joshua Martin wrote:
Ah, I see. Thanks!
On Tue, Apr 27, 2010 at 4:20 PM, Frederick Cheung <[email protected]
> wrote:
On Apr 27, 9:07 pm, Joshua Martin <[email protected]> wrote:
> I have a datetime field in the database. How do I find records for a
> particular date regardless of the time of day?
>
you need to search for records where that date column falls in the
appropriate range (ie midnight on that day until midnight on the
following day0
Fred
> The method I'm trying does not work.. tasks.find(:all, :conditions
=> ["date
> == ?", Date.today])
You might also be able to use date functions of your database engine
to simplify the query (although depending on indexing, it may not be
more performant).
tasks.find(:all, :conditions => ['DATE(date) = ?', Date.today])
Be careful with a range that entries that happen to fall exactly on
midnight aren't counted on both the preceding and following days.
-Rob
Rob Biedenharn
http://agileconsultingllc.com
[email protected]
http://gaslightsoftware.com
[email protected]
> --
> _________________________________
>
> Joshua S. Martin
--
_________________________________
Joshua S. Martin
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.