X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E5457D1B170 for ; Fri, 16 Jul 2004 05:45:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20076-05 for ; Fri, 16 Jul 2004 08:45:33 +0000 (GMT) Received: from smtp.ualg.pt (smtp.ualg.pt [193.136.224.8]) by svr1.postgresql.org (Postfix) with ESMTP id 23F1CD1B376 for ; Fri, 16 Jul 2004 05:45:29 -0300 (ADT) Received: from localhost (smtp.ualg.pt [127.0.0.1]) by smtp.ualg.pt (Postfix) with ESMTP id 2B0D74BE5C for ; Fri, 16 Jul 2004 09:45:29 +0100 (WEST) Received: from smtp.ualg.pt ([127.0.0.1]) by localhost (smtp.ualg.pt [127.0.0.1]) (amavisd-new, port 10024) with SMTP id 06515-01 for ; Fri, 16 Jul 2004 09:45:25 +0100 (WEST) Received: from ualg.pt (corisco.uceh.ualg.pt [10.10.20.126]) by smtp.ualg.pt (Postfix) with ESMTP id BA0614BDFD for ; Fri, 16 Jul 2004 09:45:24 +0100 (WEST) Message-ID: <40F795A4.5030206@ualg.pt> Date: Fri, 16 Jul 2004 09:45:24 +0100 From: Luis Sousa User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Debian/1.6-5 X-Accept-Language: en-pt MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Problem in age on a dates interval Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/97 X-Sequence-Number: 18349 Hi all, I'm using PostgreSQL 7.3.3 on i386-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3 (Debian), and I don't understand the results of the following queries: SELECT age('2004-05-14 16:00'::timestamp,'2004-02-18 16:00'::timestamp); age ---------------- 2 mons 25 days SELECT '2004-02-18 16:00'::timestamp+'2 mons 25 days'::interval; ?column? --------------------- 2004-05-13 16:00:00 In this case, the age from 2004-05-14 16:00 to 2004-02-18 16:00 is 2 mons 25 days, but if I add the age to the initial date, it returns one day less!? SELECT age('2004-05-26 16:00'::timestamp,'2004-02-18 16:00'::timestamp); age --------------- 3 mons 8 days SELECT '2004-02-18 16:00'::timestamp+'3 mons 8 days'::interval; ?column? --------------------- 2004-05-26 16:00:00 Here, the age between 2004-05-26 16:00 and 2004-02-18 16:00 is 3 mons 8 days, and this interval added to the initial date gives the correct result!! Best regards, Luis Sousa