tags:

views:

40

answers:

2

Hi all.. I want 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..

+2  A: 

Try using the DATEPART function:

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

Use varchar(5) instead of varchar(8)

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