SQL中两个日期的查询语句怎么写?

日期的查询语句?between...and...忘记具体怎么写了?

第1个回答  2019-08-24
这个要区分数据库的。如果是informix、mysql、sybase可以直接以字符串形式查询,如果是oracle那就需要加to_date函数。
不用写什么between
and
,直接写大于小于号即可。
写字符串的时候注意标准格式:2012-04-20
10:00:00
或者2012/04/20
10:00:00
第2个回答  2019-11-04
查询当前系统时间为select
sysdate
from
dual;
查询两个日期之间的月数(date1-date2)用months_between(date1,date2)单值函数。例如:
select
months_between(hiredate,sysdate)
from
emp;
第3个回答  2019-06-25
你是条件带两个日期,还是想提取两个日期字段?
SELECT
rq1,rq2
from
table_name
where
To_Char
(rq1,
'yyyy-mm-dd')
BETWEEN
'2012-04-01'
AND
'2012-04-01'
;
第4个回答  2020-02-02
select
*
from
表名
where
time>=#2016-06-03#
time字段可以是时间格式:如
2016-7-28
21:36:00
相似回答