Reputation: 194
I am not able to obtain the date object from date string 2019-01-21T19:02:25Z
select to_char(to_date('2019-01-21T19:02:25Z','yyyy-mm-ddThh24:mi:ssZ'),'dd/mm/yyyy hh24:mi:ss') from dual;
yields
ORA-01821: date format not recognized 01821. 00000 - "date format not recognized" *Cause:
*Action:
May I know what date format is used.
Upvotes: 0
Views: 1113
Reputation: 167867
Either use quotes to match the T
and Z
as literals:
SELECT TO_CHAR(
TO_DATE(
'2019-01-21T19:02:25Z',
'yyyy-mm-dd"T"hh24:mi:ss"Z"'
),
'dd/mm/yyyy hh24:mi:ss'
)
FROM DUAL;
or, match the T
as a literal and use TO_TIMESTAMP_TZ
with the TZH
and TZM
format models to match the time zone hours and minutes components (or, instead, TZR
to match the time zone region):
SELECT TO_CHAR(
TO_TIMESTAMP_TZ(
'2019-01-21T19:02:25Z',
'yyyy-mm-dd"T"hh24:mi:ssTZHTZM'
),
'dd/mm/yyyy hh24:mi:ss'
)
FROM DUAL;
Upvotes: 5