Skip to Main Content

Analytics Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting YTD and MTD dates out of sysdate

User_UV9JRJan 15 2022

Hello experts,
i have a situation where i need to get the YTD and MTD out of sysdate.
the query i am using is below:
select TRUNC(sysdate, ‘year’)-1 from dual as YTD /* this is not giving desired result, giving 12/31/2021 which is not correct it must be 1/1/2021 */
select TRUNC(sysdate, ‘mon’)-1 from dual as MTD /* gave 12/31/2021 when ran on jan 13 2022 */
Please help me in getting correct ytd and mtd dates

Comments