SELECT to_number(TO_CHAR(add_months(trunc(sysdate, 'yy'), ROWNUM - 1), 'MM')) as month
FROM DUAL
CONNECT BY ROWNUM <=
(select months_between(trunc(sysdate, 'mm'), trunc(sysdate, 'yy')) + 1
from dual);

当然,也可以指定具体的时间段,只要把months_between里面的两个日期改成具体的日期就行,

其中,trunc(sysdate, 'mm')是返回当月的第一天,trunc(sysdate, 'yy')是返回当年的第一天。

trunc的其他用法可以参考博文:

相关文章:

  • 2021-06-11
  • 2022-12-23
  • 2021-12-20
  • 2021-12-07
  • 2021-11-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
相关资源
相似解决方案