+ -
当前位置:首页 → 问答吧 → SQL语句求解 时间

SQL语句求解 时间

时间:2011-12-22

来源:互联网

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

作者: sunxunbendan   发布时间: 2011-12-22

case when ... then 
  when ... then
..........

作者: fredrickhu   发布时间: 2011-12-22