sql语句 时间

来源:百度知道 编辑:UC知道 时间:2024/05/24 02:55:24
如何查询 早晨7:00 到 晚上 19:30 的数据
还有 早晨7:00 到 晚上 19:30 这个时间段以外的数据

有没有指定哪一天啊
select * from 表名 where 时间列 between '2009-1-1 7:00 ' and ''2009-1-1 19:30 '
以外的就用
select * from 表名 where 时间列 not between '2009-1-1 7:00 ' and ''2009-1-1 19:30 '

没有指定哪天就要用datepart

select * from 表名 where 时间列 between '2009-1-1 7:00 ' and ''2009-1-1 19:30 '

顶下二楼!