Re: Unexpected behaviour of date_part

From: Richard Huxton <dev(at)archonet(dot)com>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unexpected behaviour of date_part
Date: 2009-06-29 09:58:10
Message-ID: 4A489032.9030205@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Albe Laurenz wrote:
>
> test=> SELECT date_part('timezone_hours', timestamp with time zone '2009-06-26 10:05:57.46624+11');
> date_part
> -----------
> 2
> (1 row)
>
> 2 being the offset of my local time zone.
>
> Now an EXPLAIN shows that this is due to the fact that the timestamp
> is converted to my local time zone before it is submitted to the function,
> but I think that this result is undesirable and misleading.

Basically, "timestamp with time zone" is a bad name for the type. If it
was called "absolute time" the behaviour would make sense. The query
below returns true, which makes sense if they are absolute times.

SELECT '29/06/2009 10:54:55+01'::timestamptz =
'29/06/2009 11:54:55+02'::timestamptz;

What would be useful sometimes is a type "timestamp AND time zone" which
stored each separately and where the above wouldn't be true. I think
it's been discussed, but no-one has done the necessary work on it.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Torsten Zühlsdorff 2009-06-29 10:43:22 Re: masking the code
Previous Message Jasen Betts 2009-06-29 09:51:11 Re: possible bug on age() function (8.2.4 , 8.3.6)