> > Why does the Netherlands (or at least my RH5.2 timezone database)
> > think you switch to DST on March 26?
> Hmmmm, maybe because we actually switched on march 26? In fact, whole of
> europe did AFAIK....
How quaint ;) The US switches this next weekend, which pushes it into
April. So it didn't occur to me that it was a DST issue at first.
And, I got off on the wrong track suggesting a solution. Having a
date_part() which works on dates explicitly doesn't really address the
issue, since you are trying to do the date_part() on a time interval,
not on an absolute date. And the time interval probably *should* keep
track of hours etc.
However, we *do* have an explicit subtraction operator for dates,
which returns a difference in days, which may be what you want:
postgres=# select '3-27-2000'::date-'3-6-2000'::date as days;days
------ 21
(1 row)
Or, force the type of the timestamp field to be date:
postgres=# select
date('3-27-2000'::timestamp)-date('3-6-2000'::timestamp) as days;days
------ 21
(1 row)
And, if you still want to do the arithmetic using timestamps, you can
force the evaluation of the input into the *same* timezone, as in this
example:
postgres=# select date_part('day','3-27-2000 CET'::timestamp-'3-6-2000 CET'::timestamp) as days;days
------ 21
(1 row)
I'm no longer thinking that an explicit date_part() for date or time
types will be useful.
HTH
- Thomas
--
Thomas Lockhart lockhart@alumni.caltech.edu
South Pasadena, California