pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedGet days between two dates?
6+ messages / 4 participants
[nested] [flat]
* Get days between two dates?
@ 2011-01-31 15:50 Emi Lu <emilu@encs.concordia.ca>
0 siblings, 3 replies; 6+ messages in thread
From: Emi Lu @ 2011-01-31 15:50 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Get days between two dates?
@ 2011-01-31 16:29 Tovo J. RABEMANANTSOA <tovo.rabemanantsoa@bordeaux.inra.fr>
parent: Emi Lu <emilu@encs.concordia.ca>
2 siblings, 0 replies; 6+ messages in thread
From: Tovo J. RABEMANANTSOA @ 2011-01-31 16:29 UTC (permalink / raw)
To: pgsql-sql
On 01/31/2011 04:50 PM, Emi Lu wrote:
> 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
>
Hi !
Yes there is : date '2001-10-01' - date '2001-09-28' returns integer '3'
(days) as said here :
http://www.postgresql.org/docs/8.4/interactive/functions-datetime.html
--
Tovo J. RABEMANANTSOA
INRA - UR1263 EPHYSE
71, Av. Edouard Bourlaux
F-33140 Villenave d'Ornon - France
Téléphone : +33 5 57 12 24 09
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Get days between two dates?
@ 2011-01-31 16:33 Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>
parent: Emi Lu <emilu@encs.concordia.ca>
2 siblings, 1 reply; 6+ messages in thread
From: Oliveiros d'Azevedo Cristina @ 2011-01-31 16:33 UTC (permalink / raw)
To: emilu@encs.concordia.ca; pgsql-sql
Doesn't the SELECT you indicated do what you need?
Best,
Oliveiros
----- 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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Get days between two dates?
@ 2011-01-31 16:36 Emi Lu <emilu@encs.concordia.ca>
parent: Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>
0 siblings, 0 replies; 6+ messages in thread
From: Emi Lu @ 2011-01-31 16:36 UTC (permalink / raw)
To: Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>; +Cc: pgsql-sql
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Get days between two dates?
@ 2011-01-31 16:39 Kenneth Marshall <ktm@rice.edu>
parent: Emi Lu <emilu@encs.concordia.ca>
2 siblings, 1 reply; 6+ messages in thread
From: Kenneth Marshall @ 2011-01-31 16:39 UTC (permalink / raw)
To: Emi Lu <emilu@encs.concordia.ca>; +Cc: pgsql-sql
On Mon, Jan 31, 2011 at 10:50:43AM -0500, Emi Lu wrote:
> 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
>
Didn't you just answer your own question?
Cheers,
Ken
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Get days between two dates?
@ 2011-01-31 16:51 Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>
parent: Kenneth Marshall <ktm@rice.edu>
0 siblings, 0 replies; 6+ messages in thread
From: Oliveiros d'Azevedo Cristina @ 2011-01-31 16:51 UTC (permalink / raw)
To: Kenneth Marshall <ktm@rice.edu>; Emi Lu <emilu@encs.concordia.ca>; +Cc: pgsql-sql
That's precisely what I think..
:-|
----- Original Message -----
From: "Kenneth Marshall" <ktm@rice.edu>
To: "Emi Lu" <emilu@encs.concordia.ca>
Cc: <pgsql-sql@postgresql.org>
Sent: Monday, January 31, 2011 4:39 PM
Subject: Re: [SQL] Get days between two dates?
> On Mon, Jan 31, 2011 at 10:50:43AM -0500, Emi Lu wrote:
>> 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
>>
>
> Didn't you just answer your own question?
>
> Cheers,
> Ken
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2011-01-31 16:51 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-01-31 15:50 Get days between two dates? Emi Lu <emilu@encs.concordia.ca>
2011-01-31 16:29 ` Tovo J. RABEMANANTSOA <tovo.rabemanantsoa@bordeaux.inra.fr>
2011-01-31 16:33 ` Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>
2011-01-31 16:36 ` Emi Lu <emilu@encs.concordia.ca>
2011-01-31 16:39 ` Kenneth Marshall <ktm@rice.edu>
2011-01-31 16:51 ` Oliveiros d'Azevedo Cristina <oliveiros.cristina@marktest.pt>
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