=> #<Gig id: 59, date: "2012-06-01 00:00:00", title: "Awesome Record", url: "http://someurl.com", body: nil, reply_email: nil, industry_id: nil, created_at: "2012-06-03 03:06:45", updated_at: "2012-06-03 03:06:45">
1.9.2-p0 :046 > Gig.where(:date => "2012-06-01 00:00:00")
Gig Load (0.3ms) SELECT "gigs".* FROM "gigs" WHERE "gigs"."date" = '2012-06-01 00:00:00'
=> []
1.9.2-p0 :043 > Gig.where(:date => "2012-06-01")
Gig Load (0.3ms) SELECT "gigs".* FROM "gigs" WHERE "gigs"."date" = '2012-06-01'
=> []
1.9.2-p0 :044 > Gig.where(:date => "June 01")
Gig Load (0.6ms) SELECT "gigs".* FROM "gigs" WHERE "gigs"."date" = 'June 01'
=> []
1.9.2-p0 :045 > Gig.where(:date => "June 1")
Gig Load (32.9ms) SELECT "gigs".* FROM "gigs" WHERE "gigs"."date" = 'June 1'
=> []
All I am trying to do is find the records in this table that have a specific ‘date’ (or even records that fall within a date range). But the basic where clause above won’t work.
What am I doing wrong?
Edit 1
I outputted the date as string, via to_s and this is the output:
d.date
=> Fri, 01 Jun 2012 00:00:00 UTC +00:00
1.9.2-p0 :079 > d.date.to_s
=> "2012-06-01 00:00:00 UTC"
Not sure if that will help….but I even tried including those strings as the condition of the where clause and it still returns an empty array.
Try these: