oracle/sql中如何将数字转换为时间戳
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19911054/
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 to convert a number into timestamp in oracle/sql
提问by user2846737
how to convert a number into timestamp(6) in oracle? ie convert 20131108 to 08-NOV-13 12.00.00.000000 AM or any format in timestamp(6). Thanks!
如何在oracle中将数字转换为时间戳(6)?即将 20131108 转换为 08-NOV-13 12.00.00.000000 AM 或时间戳 (6) 中的任何格式。谢谢!
回答by Thorsten Kettner
You convert your number to a string with to_char. Then you convert that string to timestamp with to_timestamp. Time will automatically be midnight.
您可以使用 to_char 将您的数字转换为字符串。然后使用 to_timestamp 将该字符串转换为时间戳。时间将自动为午夜。
select to_timestamp( to_char(20131108) ,'yyyymmdd') from dual