S
S
Stanislav Chernov2016-05-17 03:53:35
PostgreSQL
Stanislav Chernov, 2016-05-17 03:53:35

How to convert date from bigint to timestamp?

There is a database on Postgresql, in one of the tables there are date and time records in an incomprehensible format, examples:
Field types - bigint, you need to get timestamp
1450064047334124
1450075512512631
How to convert them into a readable form in the format 'YYYY-MM-DD HH-MM-SS' ?
Tried:
receipt_t1 = '1450064047334124'
TO_CHAR(TO_TIMESTAMP(receipt_t1 / 1000), 'DD/MM/YYYY HH24:MI:SS') getting "14/09/47920 03:42:14"
receipt_t1 = '1450064047334124'
TO_TIMEMPAR(TO_TIME (receipt_t1 / 86400), 'DD/MM/YYYY HH24:MI:SS') I get "02/11/2501 20:44:55"
I know for sure that the values ​​should be approximately equal to the date 2015-12-12

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
krypt3r, 2016-05-17
@uinx

Try like this
select to_timestamp(1450075512512631/1e6);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question