Re: SQL and function reference? - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: SQL and function reference?
Date
Msg-id 20050125170046.GA51343@winnie.fuhr.org
Whole thread Raw
In response to Re: SQL and function reference?  ("Rodolfo J. Paiz" <rpaiz@simpaticus.com>)
Responses Re: SQL and function reference?  ("Rodolfo J. Paiz" <rpaiz@simpaticus.com>)
List pgsql-novice
On Tue, Jan 25, 2005 at 10:07:35AM -0600, Rodolfo J. Paiz wrote:
>
> After a good 15 minutes of searching, I'm still looking for a way to use
> age() to get how many *days* ago something happened, expressed as an
> integer rather than an interval.

Subtracting two dates yields an integer (see the "Date/Time Operators"
table in the "Date/Time Functions and Operators" section of the
documentation).  If you have timestamps then you could cast them
to date and then subtract.  You could also use extract(epoch from
interval_value) to get the number of seconds in an interval, then
divide that by 86400 (24*60*60) to get days.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-novice by date:

Previous
From: Jason Dixon
Date:
Subject: Re: recommended programming language for postgresql
Next
From: "Paul Murphy"
Date:
Subject: Re: Problems with PL/pgSQL and LIKE statement