Re: date_trunc problem in HEAD

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

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:

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

Heck, even what I submitted, test and all is wrong:

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

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

So, unless someone else knows how to do this correctly, I'll have to actually
think about it.

Cheers,
Rob

--
12:34:02 up 47 days, 17:50, 4 users, load average: 2.34, 2.60, 2.55
Linux 2.6.5-02 #8 SMP Mon Jul 12 21:34:44 MDT 2004

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Miroslav Šulc 2005-03-13 19:51:05 Re: How to read query plan
Previous Message Miroslav Šulc 2005-03-13 19:43:58 Re: How to read query plan