Query Time range between Dates using DATETIME mysql

Viewed 11647

I have a database table that has fields as such :

TIME(Datetime)        Update_ID
2013-11-25 05:00:14     XC3
2013-11-25 06:00:13     XC4
2013-11-25 06:00:19     XC5
2013-12-25 23:00:14     XC6
2013-12-25 24:00:00     XC7

So assuming i want to find a trend on the updates to know which period of the day has the a particular number of updates, what i initially think of is doing something like this :

SELECT COUNT(TIME) FROM  table WHERE TIME between '06:00:00' and '12:00:00' 

But this doesn't work because i think since the date is not added with the time, a default value for date is added(some date around 1970). If, i add the beginning and enddate in my query, i am afraid it won't give me the results i need.

2 Answers
Related