我想在sql server中将日期时间转换为24小时,我想根据时间选择记录......!
我的表格如下
id 1 2 3
starttime 12:00:00.0000000 01:00:00.0000000 12:00:00.0000000
EndTime 23:59:59.0000000 13:59:59.0000000 23:59:59.0000000
startTime : 14/10/2013 01:02 AM and end time 14/10/2013 11:02 PM.
时应显示记录 id 2& 3
我的SQL查询如下
SELECT * FROM TableTimes
WHERE StartTime >= CONVERT(char(8),CONVERT(time,'14/10/2013 01:02 AM',103), 108)
AND [EndTime]<= CONVERT(char(8),CONVERT(time,'14/10/2013 11:02 PM',103), 108)
答案 0 :(得分:0)
你试过吗
SELECT * FROM TableTimes
HAVING StartTime >= CONVERT(char(8),CONVERT(time,'14/10/2013 01:02 AM',103), 108)
AND [EndTime]<= CONVERT(char(8),CONVERT(time,'14/10/2013 11:02 PM',103), 108)