pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeremy Schneider <schneider@ardentperf.com>
To: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Returning timestamp with timezone at specified timezone irrespective of client timezone
Date: Sun, 27 Sep 2020 16:42:53 -0700
Message-ID: <f6e2b173-1a48-dfeb-0cb9-fe10dd0b965d@ardentperf.com> (raw)
In-Reply-To: <6b269cb9-5572-acaa-de9c-fe1c705fed11@gmail.com>
References: <3af9fdd2-b622-426a-8e1e-aeab1bee8493@www.fastmail.com>
	<6b269cb9-5572-acaa-de9c-fe1c705fed11@gmail.com>

On 9/27/20 16:13, Ron wrote:
> On 9/27/20 4:16 PM, aNullValue (Drew Stemen) wrote:
>> What I need is for the ability to return a timestamp with timezone,
>> using the UTC offset that corresponds to a column-defined timezone,
>> irrespective of the client/session configured timezone.
>>
>> I have three columns in a table:
>> Timezone: 'US/Eastern'
>> Date: 2020-10-31
>> Time: 08:00
>>
>> The output I'm able to find includes these possibilities:
>> '2020-10-31 08:00:00'
>> '2020-10-31 12:00:00+00'
>>
>> Whereas what I actually need is:
>> '2020-10-31 08:00:00-05'
>>
>> Using the postgresql session-level timezone configuration won't work
>> because I need multiple timezones to be handled in a single set.
> 
> Are you really asking what the TZ offset was on a specific date (Like
> DST or not)?

IIUC, there is a gap here in PostgreSQL. i think it could most
easily/quickly be addressed with an overloaded version of to_char that
accepts a "display timezone" for its timestamp to character conversion.

FWIW - in Oracle this is handled by having two different data types:
1) TIMESTAMP WITH TIME ZONE
2) TIMESTAMP WITH LOCAL TIME ZONE

ironically, oracle's "local" data type is the equivalent PostgreSQL's
timestamp with time zone where the timestamp is converted and
processed/stored without a time zone. afaik postgresql doesn't have a
native data type equivalent to the first variant in oracle, which
actually considers the time zone as part of the data. (am i missing
something?)

in lieu of having built-in support, a PL/pgSQL function to set the
session-level timezone in between processing each record is the best
approach i've thought of so far.

-Jeremy

-- 
http://about.me/jeremy_schneider





view thread (14+ messages)  latest in thread

Message-ID: <f6e2b173-1a48-dfeb-0cb9-fe10dd0b965d@ardentperf.com>
Permalink:  ../f6e2b173-1a48-dfeb-0cb9-fe10dd0b965d@ardentperf.com/
Also on:    postgresql.org/message-id/f6e2b173-1a48-dfeb-0cb9-fe10dd0b965d@ardentperf.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: schneider@ardentperf.com, ronljohnsonjr@gmail.com
  Subject: Re: Returning timestamp with timezone at specified timezone irrespective of client timezone
  In-Reply-To: <f6e2b173-1a48-dfeb-0cb9-fe10dd0b965d@ardentperf.com>
  References: <3af9fdd2-b622-426a-8e1e-aeab1bee8493@www.fastmail.com> <6b269cb9-5572-acaa-de9c-fe1c705fed11@gmail.com> <f6e2b173-1a48-dfeb-0cb9-fe10dd0b965d@ardentperf.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox