On 7 January 2011 17:30, Robert Walker <li...@ruby-forum.com> wrote: > Robert Walker wrote in post #973147: >> Rails 2: >> @flights = Flight.find(:conditions => { :arrival_airport_id => >> departure_airport_id, :departure_datetime => @date...(@date + 1.day) }) >> >> Rails 3: >> @flights = Flight.where(:arrival_airport_id => departure_airport_id, >> :departure_datetime => @date...(@date + 1.day)) >> >> SELECT "flights".* FROM "flights" WHERE ("flights"."arrival_airport_id" >> = 1) AND ("flights"."departure_datetime" >= '2011-01-07 17:21:56.932566' >> AND "flights"."departure_datetime" < '2011-01-08 17:21:56.932568') > > Oops, The above statements are actually correct but the resulting SQL > show here was incorrect. Should have been: > > SELECT "flights".* FROM "flights" WHERE ("flights"."arrival_airport_id" > = 1) AND ("flights"."departure_datetime" >= '2011-01-07' AND > "flights"."departure_datetime" < '2011-01-08')
I think the above would only be correct if the OP is operating in UTC, generally he should make @date the UTC time for the start of the local day as the datetimes in the db will be in utc. 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.