Thread: Subtraction of Dates

Subtraction of Dates

From
"Valerie Goodman"
Date:
When I want an integer for a number of days between two dates, direct
subtraction of two dates returns an integer.

However, age function returns an interval.

Which is the correct method to use and if age is the correct method, how do
I convert that to the number of days?






Re: Subtraction of Dates

From
Steve Brett
Date:
try date_mi as opposed to direct subtraction.

eg:

edb=# select version();                           version
---------------------------------------------------------------PostgreSQL 7.0.3 on i686-pc-linux-gnu, compiled by gcc
2.95.2
(1 row)

edb=# select date_mi('2002-06-24','2002-06-21');date_mi
---------      3
(1 row)

Steve

> -----Original Message-----
> From: Valerie Goodman [mailto:VGoodman@aih.co.uk]
> Sent: 27 June 2002 14:22
> To: pgsql-sql@postgresql.org
> Subject: [SQL] Subtraction of Dates
> 
> 
> 
> When I want an integer for a number of days between two dates, direct
> subtraction of two dates returns an integer.
> 
> However, age function returns an interval.
> 
> Which is the correct method to use and if age is the correct 
> method, how do
> I convert that to the number of days?
> 
> 
> 
> 
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 
>