Forum Stats

  • 3,814,241 Users
  • 2,258,848 Discussions


Getting YTD and MTD dates out of sysdate

User_UV9JR Member Posts: 1 Green Ribbon

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