Generate a range of dates using SQL

前端 未结 15 1371
面向向阳花
面向向阳花 2020-11-28 05:47

I have a SQL query that takes a date parameter (if I were to throw it into a function) and I need to run it on every day of the last year.

How to generate a list of

15条回答
  •  醉酒成梦
    2020-11-28 06:03

    Another simple way to get 365 days from today would be:

    SELECT (TRUNC(sysdate) + (LEVEL-366)) AS DATE_ID
    FROM DUAL connect by level <=( (sysdate)-(sysdate-366));
    

提交回复
热议问题