Re: Why *exactly* is date_trunc() not immutable ?

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why *exactly* is date_trunc() not immutable ?
Date: 2007-02-18 12:19:43
Message-ID: 1D73F29F-B2DC-4393-85DF-A76DB004E2F7@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Feb 18, 2007, at 20:29 , Karsten Hilbert wrote:

> What I don't understand, however, is exactly *why* date_trunc is
> not immutable ?

I believe it's because the result of date_trunc depends on the time
zone setting for the session.

test=# select date_trunc('day', current_timestamp);
date_trunc
------------------------
2007-02-18 00:00:00+09
(1 row)

test=# set time zone 'EST5EDT';
SET
test=# select date_trunc('day', current_timestamp);
date_trunc
------------------------
2007-02-18 00:00:00-05
(1 row)

So, given the same arguments, ('day', and current_timestamp),
date_trunc is returning two different results. (Casting to date has
the same issue.)

Michael Glaesemann
grzm seespotcode net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John DeSoi 2007-02-18 13:31:08 Re: Anticipatory privileges
Previous Message Karsten Hilbert 2007-02-18 11:44:51 Re: Why *exactly* is date_trunc() not immutable ?