My database record is partly shown below, i want to use a sql to get records between a period of time in each day.
Such as i want get 01:00 - 03:00 in below records, i expect to get 2004/8/7 01:54, 2004/8/11 02:41, how should i do? Thanks:)
2004/8/7 01:54
2004/8/7 16:44
2004/8/7 22:26
2004/8/9 16:26
2004/8/9 16:26
2004/8/9 18:36
2004/8/9 18:36
2004/8/9 18:36
2004/8/9 18:36
2004/8/10 23:22
2004/8/10 23:23
2004/8/11 02:41
2004/8/12 21:05
The
HOUR()function gives you the hour of day. The rest is easy:Edited:
Note that
hour(datetime_column) between 1 and 2matches... 01:00:00to... 02:59:59and the rest matches the one other second remaining – exactly03:00:00.