Tuesday, 21 November 2023

Query for Date Parameter in the format YYYY/MM

with year as (
select yyyy from (SELECT LEVEL yyyy FROM DUAL CONNECT BY LEVEL <= EXTRACT(YEAR FROM SYSDATE)) where yyyy>=1951
),
month as (
SELECT to_char(LEVEL,'fm00') mm FROM DUAL CONNECT BY LEVEL <= EXTRACT(month FROM SYSDATE)
)
select yyyy||'/'||mm param from year y, month m
order by yyyy desc,mm desc

No comments:

Post a Comment