Re: Getting yyyy-mm-dd 00:00:00 in an arbitrary time zone - Mailing list pgsql-sql

From Tom Lane
Subject Re: Getting yyyy-mm-dd 00:00:00 in an arbitrary time zone
Date
Msg-id 9493.1141432345@sss.pgh.pa.us
Whole thread Raw
In response to Getting yyyy-mm-dd 00:00:00 in an arbitrary time zone  ("Davidson, Robert" <robdavid@amazon.com>)
List pgsql-sql
"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


pgsql-sql by date:

Previous
From: "Davidson, Robert"
Date:
Subject: Getting yyyy-mm-dd 00:00:00 in an arbitrary time zone
Next
From: "Davidson, Robert"
Date:
Subject: Re: Getting yyyy-mm-dd 00:00:00 in an arbitrary time zone