I need a sql query to get a 1st day of the 1st month of the year which i am passing.
ex: If i am passing 2021, my output should be 01-JAN-2021 If i am passing 2020, my output should be 01-JAN-2020
Advertisement
Answer
Assuming you are passing the year as the bind variable :year
then:
SELECT TO_DATE(:year||'0101','YYYYMMDD') FROM DUAL;
or
SELECT TRUNC(TO_DATE(:year,'YYYY'),'YY') FROM DUAL;