I have a datetime field in the database. How do I find records for a
particular date regardless of the time of day?
The method I’m trying does not work… tasks.find(:all, :conditions =>
[“date
== ?”, Date.today])
–
Joshua S. Martin
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the attorney
client or other legal privileges, and or proprietary non public
information.
If you are not an intended recipient of this message or an authorized
assistant to an intended recipient, please notify the sender by replying
to
this message and then delete it from your system. Use, dissemination,
distribution, or reproduction of this message and or any of its
attachments
(if any) by unintended recipients is not authorized and may be unlawful.
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the attorney
client or other legal privileges, and or proprietary non public
information.
If you are not an intended recipient of this message or an authorized
assistant to an intended recipient, please notify the sender by replying
to
this message and then delete it from your system. Use, dissemination,
distribution, or reproduction of this message and or any of its
attachments
(if any) by unintended recipients is not authorized and may be unlawful.
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).