On Jan 7, 2011, at 8:48 AM, Jim Burgess wrote: > Hi, > > I have a flight model. > I want to find all flights with a specific arrival airport, a specific > departure airport and which depart on a certain date. > > My problem is that the departure date is a datetime column in the db and > I wish to search this column by date (not datetime). > > I have written the following: > > @flights = Flight.find(:all, :conditions => ['arrival_airport_id = ? and > departure_airport_id = ? and departure_datetime >= ? and > departure_datetime < ?', @arrival_airport_id, @departure_airport_id, > @date, @date+1]) > > This works but the code seems long and ugly. > > Is this an acceptable way to do what I want, or can someone point me to > a better, 'prettier' method?
You could replace "departure_datetime >= ? and departure_datetime < ?" with "departure_datetime BETWEEN ? AND ?"... Doesn't help much though... -- 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.