SQL语句查询特定时间段的数据怎么写
SQL语句查询特定时间段的数据怎么写SQL语句查询特定时间段的数据 在我的表中有一个字段存储的是datetime格式的日期和时间。我想获得7月1号到7月31号之间每天19:20:00点到21:20:00的数据。获得这样的数据的sql
select * from 表 where 日期字段>='开始日期' and 日期字段<='截止日期'
and convert(char(8),日期字段,108)>='开始时间' and convert(char(8),日期字段,108)<='截止时间'
例如:
select * from tb1 where dDate>='2010-11-05' and dDate<='2010-11-15'
and convert(char(8),dDate,108)>='22:30:00' and convert(char(8),dDate,108)<='23:00:00'
相关内容