Skip site navigation (1) Skip section navigation (2)

Re: Date trunc in UTC

From: Richard Huxton <dev(at)archonet(dot)com>
To: Thrasher <thrasher(at)fibers(dot)upc(dot)es>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Date trunc in UTC
Date: 2002-11-20 13:06:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Wednesday 20 Nov 2002 10:37 am, Thrasher wrote:
> No I cannot use SET TIME ZONE.
> SET TIME ZONE will be set by any client backend. But what I want to get
> is that DATE_TRUNC('month', <now in timezone +1>) = DATE_TRUNC('month',
> <now in timezone -7>).

Sorry, I've obviously misunderstood. Are you just looking to discard the 
timezone so they look the same?

select date_trunc('month', CAST(CURRENT_TIMESTAMP AS timestamp without time 
 2002-11-01 00:00:00

I'd have thought that would give you some problems around local/utc midnight 
on the first of the month.

Or is it that you want to know what time it was in UTC zone at the start of 
the month local time?

If I'm still being a bit slow (quite likely) can you explain what you're using 
this for?

> >>=# select date_trunc ('month', now ());
> >>        date_trunc
> >>------------------------
> >>  2002-11-01 00:00:00+01

> >>Instead, I would like to have as a result
> >>
> >>  2002-11-01 01:00:00+01
> >>
> >>which is correct, but I cannot set the whole server to UTC. Any way to
> >>get this ?

  Richard Huxton

In response to


pgsql-sql by date

Next:From: Hugh EscoDate: 2002-11-20 13:12:33
Subject: Re: Problems invoking psql. Help please.
Previous:From: Oliver ElphickDate: 2002-11-20 12:49:27
Subject: Re: Problems invoking psql. Help please.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group