开发者

How to search in sql for hour/minutes?

开发者 https://www.devze.com 2022-12-19 10:05 出处:网络
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

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开发者_StackOverflow 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".


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


Another option is:

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

0

精彩评论

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