views:

10

answers:

0

For some reason:

Analytic.where({:ga_date.gte => '2010-09-01'}).count()   # greater than or equal to

gives back 0, but

Analytic.where({:ga_date.gte => Time.parse('2010-09-01')}).count()

gives back 230, which is the number of records (documents).

Actually, the first line on the top works in another case, so it is quite strange.

Can only the date be compared, because if it is

Analytic.where({:ga_date.lte => Time.parse('2010-09-10')}).count() # less than or equal to

then all the records with date 2010-09-10 will not be counted because Time.parse('2010-09-10') will give 2010-09-10 00:00:00, so the records will all have to be 2010-09-09 before the midnight. In other words, 2010-09-10 2am won't be included because 2am is not "less than or equal to" 00:00:00. It can be hacked by using

Analytic.where({:ga_date.lte => Time.parse('2010-09-10 23:59:59')}).count()

but it is kind of ugly. If there is a way to compare by date only like the first line of code in this post?