oracle 将具有 AM/PM 日期格式的字符串转换为 DD-MM-YYYY HH24:MI:SS 格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22718238/
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
Conversion of String having date format with AM/PM to DD-MM-YYYY HH24:MI:SS format
提问by user3346563
Might be simple but I am unable to resolve this.
可能很简单,但我无法解决这个问题。
I want to do a minus the date between 2 tables for validation- One is an external table. The external table has varchar2 for date column -format is 3/03/2014 6:00:28 AM table2 has a date datatype which is of format '03-MAR-2014 06:00:28'.
我想减去 2 个表之间的日期以进行验证 - 一个是外部表。外部表的日期列具有 varchar2 -格式为 3/03/2014 6:00:28 AM table2 具有格式为“03-MAR-2014 06:00:28”的日期数据类型。
Can someone help me with this. I am getting errors like ORA29913, ORA 01830 etc while doing minus between 2 after doing a to_date of first string
有人可以帮我弄这个吗。在执行第一个字符串的 to_date 后在 2 之间做减号时,我收到了诸如 ORA29913、ORA 01830 等错误
Thanks,
谢谢,
回答by crazycloud
for first date convert it like this
第一次约会这样转换
select to_date('3/03/2014 6:00:28 AM','DD/MM/YYYY HH:MI:SS PM') from dual
and then you can subtract date from table2 directly from this date without need for any conversion.
然后您可以直接从此日期减去 table2 中的日期,而无需任何转换。