From: Emi Lu <emilu@encs.concordia.ca>
To: Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>
Cc: pgsql-sql@postgresql.org
Subject: Re: Get days between two dates?
Date: Mon, 31 Jan 2011 11:36:45 -0500
Message-ID: <4D46E51D.6050602@encs.concordia.ca> (raw)
In-Reply-To: <4CEBB9E1DD3F4E7FAB832985202E4986@marktestcr.marktest.pt>
References: <4D46DA53.9050402@encs.concordia.ca>
<4CEBB9E1DD3F4E7FAB832985202E4986@marktestcr.marktest.pt>
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" <emilu@encs.concordia.ca>
> To: <pgsql-sql@postgresql.org>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: emilu@encs.concordia.ca, oliveiros.cristina@marktest.pt
Subject: Re: Get days between two dates?
In-Reply-To: <4D46E51D.6050602@encs.concordia.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox