On Fri, 26 Jan 2001 12:46, Glen and Rosanne Eustace wrote:
> template1=# select '31/12/2000'::date + '365 days'::timespan;
> ?column?
> ------------------------
> 2002-01-01 00:00:00+13 <<<<<<<<<<< Wrong
> (1 row)
This appears to be fixed in the current sources by CVSup :-
23:16:03 chris@berty:~ $ psql --version
psql (PostgreSQL) 7.1beta3
contains readline, history support
Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
Portions Copyright (c) 1996 Regents of the University of California
Read the file COPYRIGHT or use the command \copyright to see the
usage and distribution terms.
Winter Time:
template1=# select '30/06/2000:10:30'::timestamp as date; date
------------------------2000-06-30 10:30:00+12
(1 row)
template1=# select '30/06/2000:10:30'::timestamp + '1 year'::interval as
date; date
------------------------2001-06-30 10:30:00+12
(1 row)
Correct!!
Summer Time:
template1=# select '30/12/2000:10:30'::timestamp as date; date
------------------------2000-12-30 10:30:00+13
(1 row)
template1=# select '30/12/2000:10:30'::timestamp + '1 year'::interval as
date; date
------------------------2001-12-30 10:30:00+13
(1 row)
Correct!!
Now lets try with '365 days' instead of '1 year'
template1=# select '30/12/2000:10:30'::timestamp + '365 days'::interval as
date; date
------------------------2001-12-30 10:30:00+13
(1 row)
Correct!!
Now lets try across a leap year:
template1=# select '30/01/2004:10:30'::timestamp as date; date
------------------------2004-01-30 10:30:00+13
(1 row)
template1=# select '30/01/2004:10:30'::timestamp + '1 year'::interval as date; date
------------------------2005-01-30 10:30:00+13
(1 row)
template1=# select '30/01/2004:10:30'::timestamp + '365 days'::interval as
date; date
------------------------2005-01-29 10:30:00+13
(1 row)
Correct!!
school=# select * from day;number | name
--------+----------- 0 | Sunday 1 | Monday 2 | Tuesday 3 | Wednesday 4 | Thursday 5 | Friday
6 | Saturday
(7 rows)
school=# select name from day where number= \
(select date_part('dow','now'::datetime) as day); name
--------Sunday
(1 row)
Correct!!
The PostgreSQL Team is to be congratulated.
--
Sincerely etc.,
NAME Christopher SawtellCELL PHONE 021 257 4451ICQ UIN 45863470EMAIL csawtell @ xtra . co . nzCNOTES
ftp://ftp.funet.fi/pub/languages/C/tutorials/sawtell_C.tar.gz
-->> Please refrain from using HTML or WORD attachments in e-mails to me <<--