naspy971
naspy971

Reputation: 1391

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

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 ?

Upvotes: 1

Views: 248

Answers (1)

Jim Jones
Jim Jones

Reputation: 19653

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;

Upvotes: 1

Related Questions