1

I have been trying to convert the following varchar into date format with no luck:

12/99
01/04 

I have tried to_char(mydate, 'mm/yy') which gives me errors. Is there any way to convert this to date format even though I am missing the day?

2
  • So you have a DATE type, and you want to show the month,year only? Commented Jan 20, 2015 at 16:37
  • Yes, that is how it was entered in the Access db and I am trying to migrate the data to Oracle. I tried the to_char(to_date(mydate, 'mm/yy')). However some of the years are not correct, for example 99 ends up being 2099 instead of 1999. Commented Jan 20, 2015 at 16:40

1 Answer 1

5

You can use RR format for year:

select to_date('12/99','mm/rr') from dual --01/12/1999
select to_date('01/04','mm/rr') from dual --01/01/2004

This format get years between 1950 to 2049.

Sign up to request clarification or add additional context in comments.

2 Comments

And when the current year is 2050, it will give you different results; 12/99 will give you December 1, 2099, and 01/04 will give you January 1, 2150.
If they're executing this same code in 2050, they'll have more serious problems then that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.