Thread: varchar::timezone conversion

varchar::timezone conversion

From
"Marc Mamin"
Date:
Hi,

I'm facing an issue, where I build time stamps from a set of strings.


In this non working  example, I'm looking for a way to cast my strings
to the expected format 'timestamp' and timezone...


CREATE OR REPLACE FUNCTION "public"."timestamp_to_utcms"
(varchar,varchar) RETURNS int8 AS
$body$ SELECT EXTRACT(EPOCH FROM $1 AT TIME ZONE $2)::int8*1000;
$body$
LANGUAGE 'sql' IMMUTABLE RETURNS NULL ON NULL INPUT SECURITY INVOKER;


Thanks for your help,



Marc Mamin;