from: Oracle的文档
   IW    "Week of year (1-52 or 1-53) based on the ISO standard. "很有可能最后几天属于下一年的第一个星期,就像454周的规则一样。
还是先研究研究ISO 关于日期的standard吧!

解决方案 »

  1.   

    还有我觉得不应该是'yyyyiw',是'iw'
      

  2.   

    SQL> select to_char(to_date('20031231','yyyymmdd'),'yyyyiw') from dual;TO_CHA
    ------
    200301
    我想自能這樣解釋:年份是2003年,但是這個星期是下一年2004年的第一個星期
    SQL>  select to_char(to_date('20040104','yyyymmdd'),'yyyyiw') from dual;TO_CHA
    ------
    200401
    SQL> select to_char(to_date('20040105','yyyymmdd'),'yyyyiw') from dual;TO_CHA
    ------
    2004022003年的12月29到31和2004年的一月1到4號是2004年的第一個星期的
      

  3.   

    SQL> select to_char(to_date('20040104','yyyymmdd'),'yyyyiw') from dual;TO_CHA
    ------
    200401
    我覺得結果應該是200402.
    SQL> select to_char(to_date('20031229','yyyymmdd'),'yyyyiw') from dual;TO_CHA
    ------
    200301
    這個結果更是奇怪。ISO應該不會這樣吧?
      

  4.   

    it's ok. pls refer to the iso standard.
    ISO 8601   Representation of dates and times.
               This standard defines a lot of details of the calendar.
               E.g. the ISO definition of the week numbers is that the 
               first day (day number 1) of a week is Monday and that the 
               first week in a year (week number 1) is the week that includes
               the first Thursday in January, i.e. the first week that has at
               least four days in January.
      

  5.   

    SQL> select to_char(to_date('20000101','yyyymmdd'),'yyyyiw') from dual;TO_CHA
    ------
    200052
    我越搞越糊塗了。上面的ISO規定好象不詳細吧?哪裡有詳細資料?