Sam
Sam

Reputation: 25

Oracle SQL Date Format

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?

Upvotes: 1

Views: 648

Answers (1)

Aramillo
Aramillo

Reputation: 3216

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.

Upvotes: 5

Related Questions