views:

22

answers:

2

I'm trying to query for records in the TimeSlot table by the field start_date which has type datetime. Here's what I've tried so far that's failed:

TimeSlot.where(:start_date => DateTime.new(2010, 9, 1))

TimeSlot.where(:start_date => DateTime.new(2010, 9, 1).to_s)

TimeSlot.where(:start_date => "2010-09-08")

TimeSlot.where(:start_date => "2010-09-08 00:00:00")

I'd appreciate any help.

A: 

Your queries look good to me.

Are you sure that you have a matching row in the db?

To debug, look in your logs/development.log file.

Added:

Problem could be timezones. Your query is using your server's timezone. Your data could be stored in a different timezone.

Larry K
A: 

I'm betting it is a timezone thing as well. Everything in the DB is automatically converted to UTC by rails. Queries 1 and 4 should work if there isn't an offset.

mpearce