I want to get date and time from a 19 digit number in Oracle and could not find any solution for this big numbers. The time should be in the format HH24:MI:SS. I am able to retrieve the date but unable to get the time.
**Example Numbers to get the date and time:
1190205161950369000 , 1190206092859146000 , 1181230172734928000 , 1181108121251823000
For this numbers above, I added them an addition value "19000000000000000000" and substring first 8 digits from the total value so that the first 8 digits give me the date(yyyymmdd).
For Example :
SUBSTR(1190205161950369000+19000000000000000000,0,8) = 20190205
Hence, the date is 05-02-2019(DD-MM-YYYY). But to get the time, even if I increase the substring length from 8 to 14 or 18 still I only get date and not time.
SQL Query Used :
Select to_date(SUBSTR(1190205161950369000+19000000000000000000,0,8),
'YYYYMMDD HH24:MI:SS') as truedate
from dual;
Result:
TRUEDATE
---------
05-02-2019
I have also tried this but does not work :
Select to_date(SUBSTR(1190205161950369000+19000000000000000000,0,14),
'YYYYMMDD HH24:MI:SS.SSSSS') as truedate
from dual;