pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Davidson, Robert <robdavid@amazon.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Getting yyyy-mm-dd 00:00:00 in an arbitrary time zone
Date: Fri, 03 Mar 2006 19:32:25 -0500
Message-ID: <9493.1141432345@sss.pgh.pa.us> (raw)
In-Reply-To: <D224B13DA625924883A3B024CD6608F001A6BB66@exchg-sea5-03.ant.amazon.com>
References: <D224B13DA625924883A3B024CD6608F001A6BB66@exchg-sea5-03.ant.amazon.com>

"Davidson, Robert" <robdavid@amazon.com> writes:
> I am trying to find out what the last full day of data for an arbitrary =
> timezone (generally not the pg client's timezone). I get the =
> max(timestamp), then would like to remove the time portion. Sounded like =
> a job for date_trunc, unfortunately date_trunc is not timezone aware:

> select (date_trunc('day', '2006-01-31 23:00:00-800' at time zone 'CST')) =
> at time zone 'CST'
> 2006-01-31 22:00:00-08

> Since the client is in PST, the truncated date is returned as 2006-02-01 =
> PST which is two hours before the desired time.

You're being quite unclear about what you want, but AFAICS the above
expression does exactly what you asked for.  Namely, you get a time that
is midnight in the CST zone and then is adjusted to your current
timezone for display.

Perhaps you could be more clear about why you don't like this result?

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <9493.1141432345@sss.pgh.pa.us>
Permalink:  ../9493.1141432345@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9493.1141432345@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robdavid@amazon.com
  Subject: Re: Getting yyyy-mm-dd 00:00:00 in an arbitrary time zone
  In-Reply-To: <9493.1141432345@sss.pgh.pa.us>

* 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