X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 24000D1C50B for ; Tue, 2 Dec 2003 11:54:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 98768-05 for ; Tue, 2 Dec 2003 07:54:19 -0400 (AST) Received: from dyatel.antar.bryansk.ru (unknown [195.239.214.85]) by svr1.postgresql.org (Postfix) with ESMTP id 0611AD1B457 for ; Tue, 2 Dec 2003 07:54:16 -0400 (AST) Received: from fduch by dyatel.antar.bryansk.ru with local (Exim 4.24; FreeBSD) id 1AR96C-0009IM-8C; Tue, 02 Dec 2003 14:53:48 +0300 Date: Tue, 2 Dec 2003 14:53:48 +0300 From: "Alexander M. Pravking" To: Bob Smith Cc: pgsql-sql Subject: Re: Problem with intervals Message-ID: <20031202115348.GK87728@dyatel.antar.bryansk.ru> References: Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/18 X-Sequence-Number: 16184 On Mon, Dec 01, 2003 at 09:09:20PM -0800, Bob Smith wrote: > I'm getting an unexpected result using intervals in an expression: > > select ('2003-10-26 0:00:00'::timestamp + '1 day'::interval)::date; > date > ------------ > 2003-10-26 > (1 row) Try using '2003-10-26 0:00:00'::date + 1; integers do not lie ;-) > When I get rid of the date cast it becomes clear what is happening: > > select '2003-10-26 0:00:00'::timestamp + '1 day'::interval; > ?column? > ------------------------ > 2003-10-26 23:00:00-08 > (1 row) > > Is this a Postgres bug, or is this correct SQL behavior? I'm running > Postgres 7.2.2. It has been discussed several times, Tom Lane offered to add 'day' as a separate interval unit (like 'second' and 'month' at this moment), but noone took a shot at it, AFAIK. Note also, that in 7.3 "timestamp" means "timestamp without time zone", while in 7.2 it's "timestamp with time zone". -- Fduch M. Pravking