Issue with closure report after upgrade to version 8.3

Issue with closure report after upgrade to version 8.3

After MSP upgrade, database changed from MySql to PostgreSQL and now the below query is giving errors.

Please help.

SELECT sdo.NAME "Site",qd.QUEUENAME "Group",cd.CATEGORYNAME "Category",wo.WORKORDERID "Request ID",wof.UDF_CHAR1 "Type",ti.FIRST_NAME "Technician",longtodate(wo.CREATEDTIME) "Created Time",longtodate(wo.COMPLETEDTIME) "Completed Time",wo.TITLE "Subject",UNIX_TIMESTAMP(DATE_FORMAT(FROM_UNIXTIME(wo.COMPLETEDTIME/1000) ,'%Y-%m-%d %H:%i:%s')) - UNIX_TIMESTAMP( DATE_FORMAT(FROM_UNIXTIME(wo.CREATEDTIME/1000) ,'%Y-%m-%d %H:%i:%s'))\n "Closed In"\n FROM WorkOrder wo LEFT JOIN ModeDefinition mdd ON wo.MODEID=mdd.MODEID LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN CategoryDefinition cd ON wos.CATEGORYID=cd.CATEGORYID LEFT JOIN SDUser td ON wos.OWNERID=td.USERID LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID LEFT JOIN StatusDefinition std ON wos.STATUSID=std.STATUSID LEFT JOIN SiteDefinition siteDef ON wo.SITEID=siteDef.SITEID LEFT JOIN SDOrganization sdo ON siteDef.SITEID=sdo.ORG_ID LEFT JOIN WorkOrder_Fields wof ON wo.WORKORDERID=wof.WORKORDERID LEFT JOIN WorkOrder_Queue woq ON wo.WORKORDERID=woq.WORKORDERID  LEFT JOIN QueueDefinition qd ON woq.QUEUEID=qd.QUEUEID WHERE  (((std.STATUSNAME = 'Closed') AND (((longtodate(wo.COMPLETEDTIME) >= (UNIX_TIMESTAMP(DATE_FORMAT(NOW(),'%Y-%m-01 H:i:s') - INTERVAL 1 MONTH)*1000)) AND ((longtodate(wo.COMPLETEDTIME) != 0) AND (longtodate(wo.COMPLETEDTIME) IS NOT NULL))) AND ((longtodate(wo.COMPLETEDTIME) < (UNIX_TIMESTAMP(DATE_FORMAT(CURDATE(), '%Y-%m-01 H:i:s'))*1000)) AND (((longtodate(wo.COMPLETEDTIME) != 0) AND (longtodate(wo.COMPLETEDTIME) IS NOT NULL)) AND (longtodate(wo.COMPLETEDTIME) != -1))))) AND (wo.SITEID IN (3904,23702,12904,18602,9901,8403,17406,903,1501,16502,9002,20104,21903,17702,11101,21904,14706,14102,24601,12905,8101,21901,13202,10801,1204,4801,15003,18902,7203,601,12601,8702,3602,3603,4503,19504,5404,15302,22801,18304,1203,23402,15002,7202,13501,12902,7505,10201,22802,16801,17102,14404,14101,12302,5103,14704,21002,5405,8701,12001,10501,15902,13802,13805,13801,21302,16202,1802,3,21602,23101,9001,7502,17703,7801,19802,21902,19201,22804,2704,17404,22502,13803,7504,4202,4204,9301,18001,20701,14402,11402,8402,11102,20702,20401,20707,15602,17704,16203,17402,20709)))  AND wof.UDF_CHAR1='Incident' AND wo.ISPARENT='1' AND (longtodate(wo.CREATEDTIME) >= (UNIX_TIMESTAMP(DATE_FORMAT(NOW(),'%Y-%m-01 H:i:s') - INTERVAL 1 MONTH)*1000)) AND (longtodate(wo.CREATEDTIME) < (UNIX_TIMESTAMP(DATE_FORMAT(CURDATE(), '%Y-%m-01 H:i:s'))*1000))