oracle周相减

比如我有一date,如2010-06-18 12:00:00,而这个日期是在24周,我希望减一周,即输入条件:'2010-06-18 12:00:00'(24周)
结果为:'2010/23'(23周)

select to_char(to_date('2010-06-18 12:00:00','yyyy-mm-dd hh24:mi:ss')-7,'yyyy/iw') from dual;

这里主要涉及到iw这个参数,对应的还有个ww参数,官方的解释为:
The week numbers returned by the WW format mask are calculated according to the following algorithm: int(dayOfYear+6)/7. This algorithm does not follow the ISO standard (2015, 1992-06-15).

To support the ISO standard, the IW format element is provided. It returns the ISO week number. In addition, the I, IY, IYY, and IYYY format elements, equivalent in behavior to the Y, YY, YYY, and YYYY format elements, return the year relating to the ISO week number.
温馨提示:答案为网友推荐,仅供参考