Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id F12CF63244D for ; Tue, 19 May 2009 06:17:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 61894-05 for ; Tue, 19 May 2009 06:17:04 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail2007.strasbourg.4js.com (mail2007.strasbourg.4js.com [84.14.60.197]) by mail.postgresql.org (Postfix) with ESMTP id 97BCF632193 for ; Tue, 19 May 2009 06:17:04 -0300 (ADT) Received: from fox.strasbourg.4js.com (fox.strasbourg.4js.com [10.0.0.196]) (authenticated bits=0) by mail2007.strasbourg.4js.com (8.13.8/8.13.8/Debian-3) with ESMTP id n4J9H0Yn017905 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 19 May 2009 11:17:00 +0200 Message-ID: <4A127919.7080105@4js.com> Date: Tue, 19 May 2009 11:17:13 +0200 From: Sebastien FLAESCH Organization: Four J's Development Tools User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Re: INTERVAL SECOND limited to 59 seconds? References: <4A127038.3010103@4js.com> <4A12737F.1020207@archonet.com> In-Reply-To: <4A12737F.1020207@archonet.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.94/9369/Tue May 19 05:46:18 2009 on mail2007.strasbourg.4js.com X-Virus-Status: Clean X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (mail2007.strasbourg.4js.com [10.10.0.1]); Tue, 19 May 2009 11:17:02 +0200 (CEST) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/622 X-Sequence-Number: 147760 I think it should be clarified in the documentation... Actually I would like to use this new INTERVAL type to store IBM/Informix INTERVALs, which can actually be used like this with DATETIME types: > create table t1 ( > k int, > dt1 datetime hour to minute, > dt2 datetime hour to minute, > i interval hour(5) to minute ); Table created. > insert into t1 values ( 1, '14:45', '05:10', '-145:10' ); 1 row(s) inserted. > select dt1 - dt2 from t1; (expression) 9:35 <- INTERVAL expression 1 row(s) retrieved. > select 15 * ( dt1 - dt2 ) from t1; (expression) 143:45 <- INTERVAL expression 1 row(s) retrieved. The PostgreSQL documentation says: The interval type has an additional option, which is to restrict the set of stored fields by writing one of these phrases: YEAR MONTH DAY HOUR MINUTE SECOND YEAR TO MONTH DAY TO HOUR DAY TO MINUTE DAY TO SECOND HOUR TO MINUTE MINUTE TO SECOND Does that mean that the [field] option of the INTERVAL type is just there to save storage space? Confusing... Seb Richard Huxton wrote: > Sebastien FLAESCH wrote: >> Hello, >> >> Can someone explain this: >> >> test1=> create table t1 ( k int, i interval second ); >> CREATE TABLE >> test1=> insert into t1 values ( 1, '-67 seconds' ); >> INSERT 0 1 >> test1=> insert into t1 values ( 2, '999 seconds' ); >> INSERT 0 1 >> test1=> select * from t1; >> k | i >> ---+----------- >> 1 | -00:00:07 >> 2 | 00:00:39 >> (2 rows) >> >> I would expect that an INTERVAL SECOND can store more that 59 seconds. > > I didn't even know we had an "interval second" type. It's not entirely > clear to me what such a value means. Anyway - what's happening is that > it's going through "interval" first. So - '180 seconds' will yield > '00:03:00' and the seconds part of that is zero. > > The question I suppose is whether that's correct or not. An interval can > clearly store periods longer than 59 seconds. It's reasonable to ask for > an interval to be displayed as "61 seconds". If "interval second" means > the seconds-only part of an interval though, then it's doing the right > thing. >