Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert oracle date string to SQL Server datetime

In a SQL Server 2000 DB, I have a table which holds string representations of Oracle DB dates. They are formatted like "16-MAY-12". I need to convert these to datetime. I can not seem to find a conversion style number that matches, nor can I find a function that will allow me to specify the input format. Any ideas?

like image 957
Nate Avatar asked May 07 '26 00:05

Nate


1 Answers

This seems to work for me:

SELECT CONVERT(DATETIME, '16-MAY-12');

You can also try using TO_CHAR() to convert the Oracle values to a more SQL Server-friendly format (best is YYYYMMDD) before pulling them out of the darker side.

like image 141
Aaron Bertrand Avatar answered May 11 '26 06:05

Aaron Bertrand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!