0

I have this timestamp value: 1568387621 I need to convert it to date.

I tried something like:

SELECT TO_TIMESTAMP('19700101','yyyymmdd') + ((1568387621/1000)/24/60/60)
FROM dual;

But it doesn't work.

My timezione is Europe/Rome.

Some conversion websites tell me the value converted is: 2019-09-13 17:13:41 Instead, in the best case on db I obtain: 2019-09-13 15:13:41

Which hour is correct (15 or 17). How can I convert it correctly?

Ork
  • 61
  • 6

2 Answers2

3

In order to cover time zone use this one:

(TIMESTAMP '1970-01-01 00:00:00 UTC' + 1568387621 * INTERVAL '1' SECOND) AT 'Europe/Rome'
Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • Thank you very much: SELECT (TIMESTAMP '1970-01-01 00:00:00 UTC' + 1568387621 * INTERVAL '1' SECOND) AT time zone 'Europe/Rome' FROM dual; worked fine – Ork Sep 16 '19 at 10:12
-2

SQL Server's TIMESTAMP datatype has nothing to do with a date and time!

Read first answer here:

How to convert SQL Server's timestamp column to datetime format