数据库按年月查询语句

来源:互联网 发布:选股策略 编程 编辑:程序博客网 时间:2024/05/16 15:01

当需要对数据库中date数据段(字段名pdate)的年、月、日查询时,

分别使用year(pdate)、month(pdate)、day(pdate)查询。

如要查询特定月份的记录,sql语句如下:

select * from table1 where year(pdate)='2010' and month(pdate)='12';