时间段查询数据库

来源:百度知道 编辑:UC知道 时间:2024/05/18 06:29:54
有一个表table里,有个字段为time,如何查询某个时间段的数据,例如(2008-01-01至 2008-02-01之间的所有数据)
1楼的好象不行!“'to_date' 不是可以识别的 函数名。”
数据库为SQL Server2000
2,3楼也是和1楼一样!!“‘date’不是可以识别的 函数名”

select * from table where
date(time) between
('2008-01-01') and ('2008-02-01' )

to_date这个函数部分数据库不支持,不是错的。
比如db2不支持,但是orcl支持

你是什么数据库,不同数据库的函数名不一样
试一下:
select * from table where DATE(time) between '2008-01-01' and '2008-02-01'

select * from table where time between to_date('2008-01-01','YYYY/MM/DD') and to_date('2008-02-01','YYYY/MM/DD')

select * from table where time between #2008-1-1# And #2008-2-1#