如何将 SQL Server 日期格式转换为 Oracle?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/976616/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I convert a SQL Server date format to Oracle?
提问by Sathyajith Bhat
I am working on migration of data from an old system to a new system. As part of migration, the data from the legacy system, (stored in files) is pumped into MS SQL Server. Now my app runs on Oracle. I'm having a problem with the date/timestamp.
我正在将数据从旧系统迁移到新系统。作为迁移的一部分,来自旧系统的数据(存储在文件中)被泵入 MS SQL Server。现在我的应用程序在 Oracle 上运行。我的日期/时间戳有问题。
The timestamp format in MS SQL Server data is:
MS SQL Server 数据中的时间戳格式为:
2008.12.23 00:00:00
2008.12.23 00:00:00
Oracle expects:
甲骨文期望:
23/12/2008 00:00:00
23/12/2008 00:00:00
or
或者
23-DEC-2008 00:00:00
2008 年 12 月 23 日 00:00:00
What would be the best way to import the data? Oracle's to_date()
function didn't work as I thought it would.
导入数据的最佳方式是什么?Oracle 的to_date()
功能并没有像我想象的那样工作。
回答by DCookie
I assume you're using insert statements?
我假设您正在使用插入语句?
Convert your dates using:
使用以下方法转换您的日期:
TO\_DATE(sql\_server\_value,'YYYY.MM.DD HH24:MI:SS')
回答by belgariontheking
You can put a second parameter on the to_date function to specify in what format the incoming data is. You will likely have to make SQL server pump the data out as a string.
您可以在 to_date 函数上放置第二个参数来指定传入数据的格式。您可能必须让 SQL Server 将数据作为字符串输出。