读书人

oracle 初级菜鸟着急地问个日期匹配的

发布时间: 2011-12-10 22:22:01 作者: rapoo

oracle 初级菜鸟着急地问个日期匹配的问题
有个列列出了日期,其值形如:2006-9-3
我就找2006年的纪录,如何写
select * from this_table where this_table.rcddate= 2006 ??????不对,怎么改

[解决办法]
查询为2006年的纪录
select * from this_table where to_char(this_table.rcddate, 'YYYY ')= '2006 '

查询为200608月份的纪录
select * from this_table where to_char(this_table.rcddate, 'YYYYMM ')= '200608 '

查询为20060831月份的纪录
select * from this_table where to_char(this_table.rcddate, 'YYYYMMDD ')= '20060831 '


读书人网 >oracle

热点推荐