Skip to Main Content

SQL & PL/SQL

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!

to_date function is not working properly

MuzzJul 2 2020 — edited Jul 2 2020

hi all

I don't know what is happening, please see the below commands for sample

Sample data and Query

with datum as

(

select '07/02/2020' rundate from dual

)

select rundate,

to_char(to_date(rundate,'mm/dd/yyyy') -1 ,'Mon-yy') date1 ,

to_char(add_months(to_date(rundate,'mm/dd/yyyy'),-1) ,'Mon-yy') date2

from datum

Query Result

rundate          date1          date2

07/02/2020      Jul-20      Jun-20

My question is that why date1 is not doing minus 1 month. It was working fine before but now it is not working.

For testing I use different logic in date2 by using add_months and it is working fine. Please advise

Muz

This post has been answered by Frank Kulash on Jul 2 2020
Jump to Answer
Comments
Post Details
Added on Jul 2 2020
2 comments
385 views