通常写法:
select * from Table where DateTimeField between '2010-01-01' and '2010-01-31'
SQL实际查询到的结果是1月1日至1月30日的全部数据,因为默认的时间为00:00:00
要取得当月的真实数据应该如下:
select * from Table where DateTimeField between '2010-01-01 00:00:00' and '2010-01-31 23:59:59'
通常写法:
select * from Table where DateTimeField between '2010-01-01' and '2010-01-31'
SQL实际查询到的结果是1月1日至1月30日的全部数据,因为默认的时间为00:00:00
要取得当月的真实数据应该如下:
select * from Table where DateTimeField between '2010-01-01 00:00:00' and '2010-01-31 23:59:59'