开发者

How to get record in between time range

I want 开发者_JS百科to fetch some result from table depending on time range so i did

SELECT * FROM TABLE where convert(varchar(10),CountryTime,108) between '15:00' and '16:00'

CountryTime- is of varchar type.. but iam not getting corect output plz suggets..


Try using the DATEPART function:

SELECT * FROM TABLE
where DATEPART(HOUR, CountryTime) IN (15, 16)


Use varchar(5) instead of varchar(8)

  SELECT * 
  FROM TABLE 
  where convert(varchar(5),CountryTime,108) between '15:00' and '16:00' 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜