如何将当前日期从Oracle的日期和日期开始持续到6个季度?

时间:2017-09-15 08:23:22

标签: sql oracle

这是九月份。我想要当前季度从日期和迄今为止以及过去6个季度的日期和迄今为止?

2 个答案:

答案 0 :(得分:0)

with Nums (NN) as
(
select level - 1
from dual
connect by level <=7
)

select add_months(trunc(sysdate,'Q'), -3*NN) as startdate,
       add_months(trunc(sysdate,'Q'), -3*NN +3)-1 as enddate
from Nums

答案 1 :(得分:0)

从双级连接中选择sysdate级别&lt; = to_char(sysdate,&#39; ddd&#39;) - to_char(add_months(sysdate,-6),&#39; ddd&#39;);