日期:2014-05-17  浏览次数:21005 次

日期查询小问题,在线..马上结.
date

2005-3-11
2005-02-11
.
.
.

 数据库里有这两种格式的数据.

我想查出大于等于2005年2月份的数据怎么查.

我试了一下.date>='2005-02' 和date>='2005-2'查出来的不一样.

谢谢.



------解决方案--------------------
to_char(date,'yyyy-mm')>='2005-02'
------解决方案--------------------
select sysdate-100 from dual 计算出是那一天
select * from table where optdate>sysdate-100

------解决方案--------------------
SELECT * FROM TABLE
WHERE
date > '2005' and substr(date,1,4)='2005'
and to_number(substr(date,instr(date,'-')+1,instr(date,'-',-1)-instr(date,'-')-1)) >= 2 

------解决方案--------------------
select * from table where date > substr(todate(2005-02-11,'yyyy-mm-dd'),1,7)