ActiveRecords queries: .where vs .find

I have a dataset, which contains a day column that I would like to
retrieve results on. Is there any reason why daily_stats.where(‘day =
Date(?)’, dte).first returns and empty set,
daily_stats.find(:first, :conditions => [‘date(day) = ?’, dte])
returns the correct data and daily_stats.where({:created_at =>
(date.midnight - 1.day)…date.midnight}).first returns the wrong
data(returns data the for the day before)?

On Fri, Nov 5, 2010 at 8:25 AM, bertly_the_coder [email protected]
wrote:

I have a dataset, which contains a day column that I would like to
retrieve results on. Is there any reason why daily_stats.where(‘day =
Date(?)’, dte).first returns and empty set,
daily_stats.find(:first, :conditions => [‘date(day) = ?’, dte])
returns the correct data and daily_stats.where({:created_at =>
(date.midnight - 1.day)…date.midnight}).first returns the wrong
data(returns data the for the day before)?

Aren’t the queries you posted totally different ones? "WHERE DATE(:dte)

day" is different from “DATE(day) = :dte”


Erol M. Fornoles

http://twitter.com/erolfornoles
http://ph.linkedin.com/in/erolfornoles

Shoot…typo…going to repost it