Re: date_trunc problem in HEAD

From: Kurt Roeckx <kurt(at)roeckx(dot)be>
To: Robert Creager <Robert_Creager(at)LogicalChaos(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: date_trunc problem in HEAD
Date: 2005-03-13 23:54:37
Message-ID: 20050313235437.GA8835@roeckx.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Mar 13, 2005 at 12:48:00PM -0700, Robert Creager wrote:
> When grilled further on (Sun, 13 Mar 2005 19:40:02 +0100),
> Kurt Roeckx <kurt(at)roeckx(dot)be> confessed:
>
> > > Attached is a patch against HEAD for your review.
> >
> > It has this comment in it:
> > /* the new year cannot be greater than the
> > * original year, so we subtract one if it is
> >
>
> Not doing to well here. When will the ISO year be greater than the current
> year? But, what I did is incorrect and 2006-01-01 shows the next problem date:

The iso year can be greater than the current year at the end of
the year and smaller on the start of the year. You have either
of those at every year change.

> SELECT '' AS date_trunc_week, date_trunc( 'week', timestamp '2006-01-01' ) AS
> week_trunc;
>
> date_trunc_week | week_trunc
> -----------------+---------------------
> | 2006-12-25 00:00:00

I expected 2005-12-26 here.

> SELECT '' AS date_trunc_week, date_trunc( 'week', timestamp '2005-01-01' ) AS
> week_trunc;
> date_trunc_week | week_trunc
> -----------------+---------------------
> | 2005-01-02 00:00:00

That's a higher date, and obviouly looks wrong. Here I expected
2004-12-27

> The date should be 2005-01-03. Sigh. Maybe I should of just submitted a bug
> report about it...

That's the next week, and not what I would expect to get as
result.

Kurt

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-03-14 00:08:41 Re: [PERFORM] How to read query plan
Previous Message Oleg Bartunov 2005-03-13 23:28:19 materialized views