大惊小怪打一生肖:SQL 问题

来源:百度文库 编辑:高考问答 时间:2024/04/28 00:44:18
我有一个表里面记录着我几年来每天每小时的数据我想按照时间查询把每天8:00的数据全查出来查询语句怎么写
是SQL SEVER 2000版本

需要知道你时间类型格式,假设为 dd MMMM yy HHmm

declare @date datetime
set @date='08'

select * from 表 where datediff(hh,字段,@date)=0

或者
select * from 表 where convert(char(13),字段,120)=convert(char(13),@date,120)

SELECT * FROM 表 WHERE datepart(hh, 日期字段) = 8