Wednesday 6 July 2022

Oracle - SQL Query to get List of Dates based on Start and End Date

Let's Take Assumptions for the Start Date and End Date.


START DATE: SYSDATE-5

END DATE: SYSDATE


Syntax:


select (SYSDATE-5) + level - 1 dt

from   dual

connect by level <= (

  (SYSDATE) - (SYSDATE-5) + 1

);


Example:


select date'2021-06-08' + level - 1 dt

from   dual

connect by level <= (

  date'2021-06-14' - date'2021-06-08' + 1

);

No comments:

Post a Comment