3
Correct way to convert the date '27/12/2016 16:31:39,137000000'
for datetime(timestamp(6)) in the oracle?
Some unsuccessful attempts that result in error ORA-01821: formato de data não reconhecido
01821. 00000 - "date format not recognized"
:
SELECT TO_CHAR(TO_DATE('27/12/2016 16:31:39,137000000', 'dd/mm/yyyy HH24:MI:SS'), 'DD/MM/YYYY') DT_C FROM DUAL;
SELECT TO_CHAR(TO_DATE('27/12/2016 16:31:39,137000000', 'dd/mm/yyyy HH24:MI:SS.FF9'), 'DD/MM/YYYY') DT_C FROM DUAL;
SELECT TO_CHAR(TO_DATE('27/12/2016 16:31:39,137000000', 'dd/mm/yyyy HH24:MI:SS.FF'), 'DD/MM/YYYY') DT_C FROM DUAL;
This works, but the date with the comma and the numbers after the seconds does not:
SELECT TO_CHAR(TO_DATE('27/12/2016 16:31:39', 'dd/mm/yyyy HH24:MI:SS'), 'DD/MM/YYYY') DT_C FROM DUAL;
the date is 12/27/2016 16:31:39,137000000
– Andrey Hartung
like, it’s literally what I get as date
– Andrey Hartung
use that code then, it is only edit the timestamp for what you want: select to_char(systimestamp,'dd-mm-yyyy hh24:mi:ss.FF') as ts from dual; OU that: SELECT TO_TIMESTAMP ('10-Sep-02 14:10:10.123000', 'DD-Mon-RR HH24:MI:SS.FF') from DUAL;
– Guilherme Reis