首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

SQL话语求解 时间

2013-01-02 
SQL语句求解 时间select*from biaoA where time between (select CONVERT(varchar(12),getdate(),23)+ 00

SQL语句求解 时间
select*from biaoA where time between (select CONVERT(varchar(12),getdate(),23)+' 00:00:00.000') and (select CONVERT(varchar(12),getdate(),23)+' 01:00:00.000')
select*from biaoA where time between (select CONVERT(varchar(12),getdate(),23)+' 01:00:00.000') and (select CONVERT(varchar(12),getdate(),23)+' 02:00:00.000')
                       .
                       .
                       .
select*from biaoA where time between (select CONVERT(varchar(12),getdate(),23)+' 23:00:00.000') and (select CONVERT(varchar(12),getdate(),23)+' 24:00:00.000')



表A有个字段为   这样 '2011-12-22 20:20:20.222' 时间  CONVERT(varchar(12),getdate(),121)的
我想把 24小时 的 所有的 SQL语句 写成1条  或者 写出 如果是 系统为1:30 分 那么就查询出 1点到2点的数据 
要根据当前的系统时间 自动跳一段时间内的数据
希望 那个大神帮忙下0 0 跪求ing

[解决办法]

select * 
from biaoA 
where time between CONVERT(varchar(13),getdate(),120)+':00:00' and 
DATEADD(hh,1,convert(varchar(13),getdate(),120)+':00:00')

热点排行