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

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Why *exactly* is date_trunc() not immutable ?
Date: 2007-02-19 12:23:48
Message-ID: 20070219122348.GP4072@merkur.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Feb 19, 2007 at 12:53:15PM +0100, Martijn van Oosterhout wrote:

> Well, your queries need to use the same form, ie:
>
> SELECT blah FROM foo
> WHERE date_trunc( 'entered_timestamp'::timestamptz AT TIME ZONE 'UTC', 'foo' )
Thought so.

> That seems a bit error prone though, so your idea of making a simple
> SQL function to wrap it will probably save you much heartache. It will
> also make it clearer to people reading the code *why* it is written
> that way.
Yep, and the COMMENT ON FUCNTION provides for a nice place to document it :-)

> > Well, PostgreSQL itself is storing UTC anyways but we need
> > the timezone bit since our frontend delivers timestamps from
> > various timezones and they are note normalized to UTC before
> > they get to the database.
>
> Yeah, the AT TIME ZONE 'UTC' needs to be put somewhere, and in the
> index is probably easier than everywhere else. Just checking you'd
> thought about it. :)
Thanks !

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Leonel Nunez 2007-02-19 12:24:40 Re: Postgresql 8.1 y Debian [ Era: Re: postgreSQL ]
Previous Message David Primero Segundo 2007-02-19 12:06:19 pgadmin3