Re: [GENERAL] setting time zone in a function

2016-04-21 Thread Tom Lane
Steve Rogerson writes: > I wonder what counts as a valid time zone http://www.postgresql.org/docs/9.5/static/datatype-datetime.html#DATATYPE-TIMEZONES > ... I wasn't expecting this: > # set timezone = '==2.77'; > SET > # select now(); > now > --- > 201

Re: [GENERAL] setting time zone in a function

2016-04-21 Thread Steve Rogerson
On 21/04/16 14:47, Tom Lane wrote: > Steve Rogerson writes: >> I want the time zone if a function a bit like ... >> CREATE OR REPLACE FUNCTION >>short_name (timestamp with time zone, varchar) RETURNS varchar AS $$ >> DECLARE >> ... >> BEGIN >> SET LOCAL TIME ZONE $2;

Re: [GENERAL] setting time zone in a function

2016-04-21 Thread Tom Lane
Steve Rogerson writes: > I want the time zone if a function a bit like ... > CREATE OR REPLACE FUNCTION >short_name (timestamp with time zone, varchar) RETURNS varchar AS $$ > DECLARE > ... > BEGIN > SET LOCAL TIME ZONE $2; Nope, that won't work: in general you can't

[GENERAL] setting time zone in a function

2016-04-21 Thread Steve Rogerson
I want the time zone if a function a bit like ... CREATE OR REPLACE FUNCTION short_name (timestamp with time zone, varchar) RETURNS varchar AS $$ DECLARE ... BEGIN SET LOCAL TIME ZONE $2; SELECT to_char($1, 'TZ')::varchar ... END $$ LANGUAGE 'plpgsq