Jiji Jiji - 2 months ago 5
SQL Question

Syntax error in date_part function in PostgreSQL

I have syntax error in following query which retrieve month from

last_updated_time
column from
BIZ_TRANSACTION
where
last_updated_time
stored as millisecond. So, how can I apply
date_part()
function?
I used the following query but it shows syntax error near
date_part()
.

SELECT date_part('month', timestamp TO_CHAR(TO_TIMESTAMP(LAST_UPDATED_TIME / 1000), 'DD/MM/YYYY HH24:MI:SS'))
FROM BIZ_TRANSACTION

Answer

If I understand your question correctly, you want something like that:

SELECT date_part('month',to_timestamp(LAST_UPDATED_TIME/1000));
FROM BIZ_TRANSACTION