sql server中一个字段为datetime类型,如何根据这个字段筛选出某天12-15点的数据

2024-12-04 12:34:26
推荐回答(5个)
回答1:

增加一个条件:
hour(datetime字段名) >=12 and hour(datetime字段名) <15

回答2:

select * from table where datepart(hh,datetime) between 12 and 15

回答3:

select [datetime] from Table where datediff('hh',[datetime],2011-05-06 12:00:00) >= 3

回答4:

where datepart(hh,字段名) between 12 and 15

回答5:

select * from table where datepart(hour,datecolumn) between 12 and 15
datecolumn 是那个datetime的列名