Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id BA2741337B8A for ; Mon, 31 Jan 2011 12:36:56 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 07516-02 for ; Mon, 31 Jan 2011 16:36:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from oldperseverance.encs.concordia.ca (oldperseverance.encs.concordia.ca [132.205.96.94]) by mail.postgresql.org (Postfix) with ESMTP id 16D991337B84 for ; Mon, 31 Jan 2011 12:36:48 -0400 (AST) Received: from cacao.encs.concordia.ca (emilu@cacao.encs.concordia.ca [132.205.47.225]) by oldperseverance.encs.concordia.ca (envelope-from emilu@encs.concordia.ca) (8.13.7/8.13.7) with ESMTP id p0VGajKO028924; Mon, 31 Jan 2011 11:36:45 -0500 Message-ID: <4D46E51D.6050602@encs.concordia.ca> Date: Mon, 31 Jan 2011 11:36:45 -0500 From: Emi Lu Reply-To: emilu@encs.concordia.ca User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20101125 Lightning/1.0b1 Thunderbird/3.0.11 MIME-Version: 1.0 To: "Oliveiros d'Azevedo Cristina" CC: pgsql-sql@postgresql.org Subject: Re: Get days between two dates? References: <4D46DA53.9050402@encs.concordia.ca> <4CEBB9E1DD3F4E7FAB832985202E4986@marktestcr.marktest.pt> In-Reply-To: <4CEBB9E1DD3F4E7FAB832985202E4986@marktestcr.marktest.pt> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.58 on oldperseverance.encs.concordia.ca at 2011/01/31 11:36:45 EST X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201101/124 X-Sequence-Number: 35071 On 01/31/2011 11:33 AM, Oliveiros d'Azevedo Cristina wrote: > Doesn't the SELECT you indicated do what you need? Ok, I figured out: age() + date_part(...) would be able to get it: select date_part('day', age(date1::timestamp, date2::timestamp) ) -- Lu Ying > > > ----- Original Message ----- From: "Emi Lu" > To: > Sent: Monday, January 31, 2011 3:50 PM > Subject: [SQL] Get days between two dates? > > >> Good morning, >> >> Is there an existing method to get days between two dates? >> >> For example, >> >> select '2010-01-01'::date - '1999-10-12'::date >> >> Returns how many days. >> >> Thank you, >> >> -- >> Lu Ying >> >> -- >> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) >> To make changes to your subscription: >> http://www.postgresql.org/mailpref/pgsql-sql -- Emi Lu, ENCS, Concordia University, Montreal H3G 1M8 emilu@encs.concordia.ca +1 514 848-2424 x5884