首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

数据库日期格式数据查询有关问题

2012-03-03 
数据库日期格式数据查询问题用下面这条语句select * from t_content t where createtime like to_date(20

数据库日期格式数据查询问题
用下面这条语句
select * from t_content t where createtime like to_date('2009-04-02','yyyy-MM-dd');
能查出所有4月2日的信息,但是用下面这条语句
select * from t_content t where createtime like to_date('2009-04','yyyy-MM'); 不能匹配出所有四月份的信息,只能查询出一条信息,是4月1日的
这是为什么呢???

[解决办法]
select * from t_content t where to_char(createtime,'yyyy-MM')='2009-04';
[解决办法]
select * from t_content t where createtime like "%to_date('2009-04','yyyy-MM')%";
 

热点排行