Oracleで文字列の日付をdatetimeに変換する

Oracleでこの文字列の日付をdatetimeに変換するにはどうすればよいのでしょうか。

2011-07-28T23:54:14Z

このコードを使用すると、エラーが発生します。

TO_DATE('2011-07-28T23:54:14Z',  'YYYY-MM-DD HH24:MI:SS')

どのようにすればよいのでしょうか?

Error report:
SQL Error: ORA-01861: literal does not match format string
01861. 00000 -  "literal does not match format string"
*Cause:    Literals in the input must be the same length as literals in
           the format string (with the exception of leading whitespace).  If the
           "FX" modifier has been toggled on, the literal must match exactly,
           with no extra whitespace.
*Action:   Correct the format string to match the literal.

更新:-

TO_DATE('2011-07-28T23:54:14Z', 'YYYY-MM-DD"T"HH24:MI:SS"Z"')

列には時間ではなく日付しか表示されません。

28-JUL-11
ソリューション

これを試してみてください。 TO_DATE('2011-07-28T23:54:14Z', 'YYYY-MM-DD"T"HH24:MI:SS"Z"')

解説 (5)

ねえ、私も同じ問題を抱えていました。TO_DATE('2017-02-20 12:15:32','YYYY-MM-DD HH24:MI:SS')`を使って、'2017-02-20 12:15:32' varcharを日付に変換しようとしたのですが、2017-02-20という時刻しか表示されませんでした。

私の解決策は、TO_TIMESTAMP('2017-02-20 12:15:32','YYYY-MM-DD HH24:MI:SS')を使うことで、時間が消えなくなりました。

解説 (1)

charへのキャストを使って、日付の結果を見ることができます。

 select to_char(to_date('17-MAR-17 06.04.54','dd-MON-yy hh24:mi:ss'), 'mm/dd/yyyy hh24:mi:ss') from dual;
解説 (0)