Thread: Timezone into/out of function

Timezone into/out of function

From
"Walker, Jed S"
Date:

Hi,

I have two functions that have a timestamp wtz passed to and return timestamps wtz in a refcursor.  The catch is that I need the timezone on the timestamp passed out to match the timezone of the timestamp passed in. I realize I can set the timezone parameter before making the call, but I'm concerned that if a user calls it with a timezone that is different than the timezone parameter the date they get won't match the timezone they requested.

Is there a way I can specify timezone as a parameter and force the timestamps in the where and select clauses to use that timezone? (without having to set the timezone parameter in the session)

Thanks

Jed.

Re: Timezone into/out of function

From
Tom Lane
Date:
"Walker, Jed S" <Jed_Walker@cable.comcast.com> writes:
> I have two functions that have a timestamp wtz passed to and return
> timestamps wtz in a refcursor.  The catch is that I need the timezone on the
> timestamp passed out to match the timezone of the timestamp passed in.

You're misunderstanding how timestamp with time zone works.  There isn't
any explicitly stored zone in a timestamptz value --- it's all GMT under
the hood.  A zone is only introduced for display.

            regards, tom lane