2

我必须使用具有特定小时和分钟的过滤器搜索所有行。

例子:

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

我想要小时/分钟“17:00”和“18:00”的所有行。日期是可选字段。

我不知道该怎么做。我正在使用“sql 任何地方 11”。

4

2 回答 2

4

请参阅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
于 2010-02-02T12:04:32.090 回答
1

另一种选择是:

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

于 2010-02-03T05:45:19.980 回答