格式化字符串到目前为止

时间:2015-07-24 14:37:57

标签: date oracle-sqldeveloper to-date

我有个约会:'7月24日星期五13:11:04 CEST 2015'。如何将此字符串转换为日期? 最终我想做那样的事情:

to_char('Fri Jul 24 13:11:04 CEST 2015', 'DD/MM/YYYY HH24:MI:SS')

我尝试了一些方法但到目前为止都失败了这个错误:

ORA-01858:  -  "a non-numeric character was found where a numeric was expected"
*Cause:    The input data to be converted using a date format model was
           incorrect.  The input data did not contain a number where a number was
           required by the format model.
*Action:   Fix the input data or the date format model to make sure the
           elements match in number and type.  Then retry the operation.

我甚至可以在这里做我想做的事吗?

1 个答案:

答案 0 :(得分:1)

您需要使用to_date

to_date('Fri Jul 24 13:11:04 CEST 2015', 'DD/MM/YYYY HH24:MI:SS')

http://ss64.com/ora/syntax-to_date.html

to_char只期待数字

http://ss64.com/ora/syntax-to_char.html