Home > Net >  How to format date as 'DD-MM-YYYY' from bigint value in PostgreSQL
How to format date as 'DD-MM-YYYY' from bigint value in PostgreSQL

Time:09-28

I'm desperately trying to figure out how to display a bigint column value which represents a timestamp into a date like 'DD-MM-YYYY'.

I tried multiple combinations, they all fail, but the only one that does not fail but does not give me exactly what I need is this :

select to_timestamp(last_downloaded/1000) from stats;

This one displays a date like 2021-08-30 15:34:08 02 but I need it to display 30-08-2021

the column 'last_downloaded' is a bigint type.

How to manage this ?

CodePudding user response:

Use to_char with the output of to_timestamp and the mask DD-MM-YYYY, e.g.

SELECT to_char(to_timestamp(last_downloaded/1000),'DD-MM-YYYY') 
FROM stats;
  • Related