The statement gives me the date and time.
How could I modify the statement so that it returns only the date (and not the time)?
SELECT to_timestamp( TRUNC( CAST( epoch_ms AS bigint ) / 1000 ) );
This question is related to
sql
postgresql
date
type-conversion
epoch
On Postgres 10:
SELECT to_timestamp(CAST(epoch_ms as bigint)/1000)
select to_timestamp(cast(epoch_ms/1000 as bigint))::date
worked for me
The solution above not working for the latest version on PostgreSQL. I found this way to convert epoch time being stored in number and int column type is on PostgreSQL 13:
SELECT TIMESTAMP 'epoch' + (<table>.field::int) * INTERVAL '1 second' as started_on from <table>;
For more detail explanation, you can see here https://www.yodiw.com/convert-epoch-time-to-timestamp-in-postgresql/#more-214
Source: Stackoverflow.com