“时间类型”的“查询”不能这样用吗???
“时间类型”的“查询”不能这样用吗???
select * from WarnUseEnergy where MeterNo in ('YD1202','YD1207','YD1205','YD1206') and
DATime between '2012-11-19 00:00:00.000' and '2012-11-19 59:59:99.999'
提示错误:
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
要查询“DATime”为“2012-11-19”的全天的数据,怎么回事呢,大师??? 应该如何修正??? ------解决方案--------------------select * from WarnUseEnergy where MeterNo in ('YD1202','YD1207','YD1205','YD1206') and DATime between '2012-11-19 00:00:00.000' and '2012-11-19
59:59:99.999'
如果是时间类型 怎么可以有59这一个小时呢 必须是23以内的啊
------解决方案--------------------and '2012-11-19 59:59:99.99
7'
最后那个改成997
------解决方案--------------------select * from WarnUseEnergy where MeterNo in ('YD1202','YD1207','YD1205','YD1206') and DATime between '2012-11-19 00:00:00.000' and
'2012-11-19 23:59:59.999'
这样就不会报错了吧
------解决方案--------------------还有就是1楼说的那个,没有59时
------解决方案--------------------and(convert(10),DATime,120)='2012-11-19'
------解决方案--------------------date>'2012-11-19' and date<'2012-11-20'