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.
------其他解决方案-------------------- 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以内的啊 ------其他解决方案-------------------- 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' ------其他解决方案-------------------- and '2012-11-19 59:59:99.997'