September 2007 Archives

Loading two-digit years into Oracle

Okay, so this problem only comes up once a century - but it's just so easy to handle. If you have some date fields you want to insert into an Oracle table - say from Excel - then your two-digit years will get expanded from 96 to 2096. What you probable want is to see 1996 rather than 2096.

The solution is really very simple, insert the year using the date operator 'RR' as apposed to 'YY'. For example let’s say Excel gives you a date string like "13. Jan 78". Using the date format to_date('13. Jan 78', 'DD. Mon RR') any year values between 0-49 will arrive in the table as 2000-2049 and values between 50-99 will arrive as 1950-1999 in your database.
If you are looking for more information check-out this link.