Ruby on Rails
Tuesday, April 27, 2010
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 <frederick.cheung@gmail.com> wrote:you need to search for records where that date column falls in the
On Apr 27, 9:07 pm, Joshua Martin <josmar52...@gmail.com> wrote:
> I have a datetime field in the database. How do I find records for a
> particular date regardless of the time of day?
>
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
--> --
> _________________________________
>
> Joshua S. Martin
_________________________________
Joshua S. Martin
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment