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

From Rodolfo J. Paiz
Subject Re: SQL and function reference?
Date
Msg-id 1106757581.5295.50.camel@rodolfo.gt.factorrent.com
Whole thread Raw
In response to Re: SQL and function reference?  (Michael Fuhr <mike@fuhr.org>)
Responses Re: SQL and function reference?
Re: SQL and function reference?
List pgsql-novice
On Tue, 2005-01-25 at 10:00 -0700, Michael Fuhr wrote:
> 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.
>

The idea here is to have a formula that says "select * from flights
where date was less than 30 days ago" and have that formula work
properly. So if I want to subtract two dates for this purpose, then I am
going to need a today() function which I also have not found.

I see now how the extract(epoch from interval) could be used, but then
why is there no extract(days|months|hours from interval), or why can I
not format an interval as "XXXXX seconds" or "YYY days"? Would make
things so much simpler!

Cheers,

--
Rodolfo J. Paiz <rpaiz@simpaticus.com>


pgsql-novice by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: Error Help
Next
From: "Rodolfo J. Paiz"
Date:
Subject: Re: SQL and function reference?