SQL 将时间戳转换为数字格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23294562/
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
Convert timestamp to number format
提问by JohnD
I have a timestampdatatype column (time_stamp_col) that stores data in the following format:
10-AUG-57 12.00.00.000000000 AM
我有一个timestamp数据类型列 ( time_stamp_col),它以以下格式存储数据:
10-AUG-57 12.00.00.000000000 AM
I need to convert it into a numberdatatype format like 19570810
我需要将其转换为number数据类型格式,如19570810
Any ideas? Thanks
有任何想法吗?谢谢
回答by D Stanley
Assuming your format is "YYYYMMDD", you should be able to use TO_CHARjust like a date field:
假设您的格式是"YYYYMMDD",您应该可以TO_CHAR像日期字段一样使用:
SELECT TO_NUMBER(TO_CHAR(time_stamp_col,'YYYYMMDD'))

