I am trying to select items between two dates. Time.zone.now seems to respect the zone value but when called as part of Active Record, it doesn’t. I am not storing my data as UTC so specifying as Time.zone.now should bring back the time of the current specified zone. How do I make this work correctly? What is the logic of the thinking?
thx
ruby-1.9.2-p290 :009 > Time.zone.now
=> Thu, 22 Mar 2012 22:26:43 PDT -07:00
ruby-1.9.2-p290 :010 > Event.where(:start_datetime => (Time.zone.now)..(Time.zone.now.end_of_day))
Event Load (0.5ms) SELECT `events`.* FROM `events` WHERE (`events`.`start_datetime` BETWEEN '2012-03-23 05:26:59' AND '2012-03-23 06:59:59')
=> []
ruby-1.9.2-p290 :011 >
Try the things like :