怎样按取两日期查询?

来源:百度知道 编辑:UC知道 时间:2024/05/26 18:48:55
SELECT * from table where '2006-11-30'<=date1 and date1<='2006-12-30' 为何这样查询出的结果不对啊?请大家帮我看看

日期要用## 括起来

SELECT * from table where date1 >= '#2006-11-30#' and date1 <='#2006-12-30#'
或者
SELECT * from table where date1 between '#2006-11-30#' and '#2006-12-30#'

SELECT * from table where date1 >= '2006-11-30' and date1 <='2006-12-30'

(一)
SELECT * from table where date1 between #2006-11-30# and #2006-12-30#
between 是介于的意思
(二)
SELECT * from table where date1 >= #2006-11-30# and date1 <=#2006-12-30#
你的语法错了 有的ACCESS版本用的是date1 >= '2006-11-30'

首先试试这个
SELECT * from table where date1 between '2006-11-30' and '2006-12-30'

如果不行时间就要精确到秒,按你的说法,你是要查12月份的,这么写:
SELECT * from table where date1 between '2006-12-01 0:0:0' and '2007-01-01 0:0:0'