Sunday, 8 July 2018

Oracle First and Last Date of current year & previous year query

–> First Day of Current Year:

SELECT TRUNC (SYSDATE , ‘YEAR’) FROM DUAL;

–> Last Day of Current Year:

SELECT ADD_MONTHS(TRUNC (SYSDATE ,’YEAR’),12)-1 FROM DUAL;

–> First Day of Previous Year:

SELECT ADD_MONTHS (TRUNC (SYSDATE,’YEAR’), -12) FROM DUAL;

–> Last Day of Previous Year:

SELECT ADD_MONTHS (TRUNC (SYSDATE, ‘YEAR’), -1 ) +30 FROM DUAL;

No comments:

Post a Comment