Hi All,
I am trying to subtract 35 months from sysdate and calculate the no of days in last 35 months with below query, it is working fine for all the months except for February.
SELECT SUM(EXTRACT(DAY FROM LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE, 'MM'), - LEVEL))))-1 EXPECTED_DAYS FROM DUAL CONNECT BY LEVEL <= 35;
On analyzing further, found that Oracle is considering 29 days for month of February in each year, even though the year is not a leap year. Can someone please suggest what changes should I make in the query to consider the days for February based on whether it's a leap year or not?
Thanks.