When grilled further on (Tue, 29 Mar 2005 07:43:53 +0200),
Dirk Raetzel <[EMAIL PROTECTED]> confessed:

> 
> 
> On Mon, 28 Mar 2005, Bruce Momjian wrote:
> 
> > I have developed a patch to fix the problem.  Instead of changing the
> > API, I added code to decrement the year when the week number was 53 and
> > the month was January.  It corrected the problem:
> 
> The problem arises as well when week number is 52 as in '2006-01-01'.

Try these at the least:

select date_trunc_week( '2004-01-01' ); -- should be 2003-12-29 00:00:00
select date_trunc_week( '2005-01-01' ); -- should be 2004-12-27 00:00:00
select date_trunc_week( '2005-06-01' ); -- should be 2005-05-30 00:00:00
select date_trunc_week( '2006-01-01' ); -- should be 2005-12-26 00:00:00
select date_trunc_week( '2007-01-01' ); -- should be 2007-01-01 00:00:00

If it helps, look earlier in this thread for a (overly complicated?) version in
plpgsql.

Cheers,
Rob

-- 
 06:39:48 up 1 day, 3 min,  9 users,  load average: 0.10, 0.24, 0.30
Linux 2.6.5-02 #8 SMP Mon Jul 12 21:34:44 MDT 2004

Attachment: pgpjHDRhF8l4n.pgp
Description: PGP signature

Reply via email to