tags:

views:

45

answers:

2

I have to search all rows with a filter with specific hour and minute.

Example:

26/05/2009 - 16:00
26/05/2009 - 17:00
10/11/2009 - 09:00
10/11/2009 - 10:00
10/11/2009 - 11:00
10/11/2009 - 12:00

I want all rows with hour/minute "17:00" and "18:00". And the date is optional field.

I don't know how to do this. I'm using "sql anywhere 11".

+3  A: 

see http://manuals.sybase.com/onlinebooks/group-pbarc/conn5/sqlug/@Generic__BookTextView/23220;pt=23220;uf=0

select  *
from    tab
where   datepart( hour, date_col )  in (17,18)
and     datepart( minute, date_col ) = 0
and     datepart( second, date_col ) = 0
Roland Bouman
+1  A: 

Another option is:

select * from tab where convert(time,date_col) in ( '17:00','18:00')

AdamH