0

我想在 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)
4

1 回答 1

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)
于 2013-10-14T13:49:22.073 回答