有个列列出了日期,其值形如:2006-9-3
我就找2006年的纪录,如何写
select * from this_table where this_table.rcddate= 2006 ??????不对,怎么改

解决方案 »

  1.   

    select * from this_table where to_char(this_table.rcddate,'YYYY')= 2006
      

  2.   

    yyyy,这么古怪,那要是月呢,mmmm?天呢?
    yyyy-mmmm-dddd??????????
      

  3.   

    查询为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'
      

  4.   

    to_char(thhis_table.rcddate,'yyyy-mm-dd')