Generate a range of dates using SQL

前端 未结 15 1372
面向向阳花
面向向阳花 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:05

     SELECT (sysdate-365 + (LEVEL -1)) AS DATES
     FROM DUAL connect by level <=( sysdate-(sysdate-365))
    

    if a 'from' and a 'to' date is replaced in place of sysdate and sysdate-365, the output will be a range of dates between the from and to date.

提交回复
热议问题