mysqldatabasepostgresqlgreenplum

How to convert MySQL CONVERT_TZ() to Postgresql


I got the below column in MySQL , I am trying to convert it into PostgreSQL but not able to do:

-- Mysql--
CONVERT_TZ(ORDER_CLOSE_DATE, 'PST8PDT', ifnull(CREATION_TIME_ZONE,'PST8PDT'))
as order_closed_date_TZ

Note : In the above I have two fields ORDER_CLOSE_DATE and CREATION_TIME_ZONE I tried with below , but where/how I will set CREATION_TIME_ZONE?

-- Postgresql-->
to_char(timezone('America/Los_Angeles',o.ORDER_CLOSE_DATE::timestamp),
'yyyy-mm-dd hh:00:00') as order_closed_date_TZ

Solution

  • I used below only then got to know I was using correct syntax:

    to_char(timezone('America/Los_Angeles',ORDER_CLOSE_DATE::timestamp),'yyyy-mm-dd hh:00:00') as order_closed_date_TZ