当前位置: 代码迷 >> 其他数据库 >> 数据库日期格式数据查询有关问题
  详细解决方案

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

热度:8485   发布时间:2013-02-26 00:00:00.0
数据库日期格式数据查询问题
用下面这条语句
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')%";
 
  相关解决方案