age('now',date::datetime)
Hello again,
I am using the age() function to determine the average shelf-life of
inventory items that are being stored in my database. And, I think the
function is definitely worth having around. It is saving me a lot of
time. However (there's always a catch), I think it would be a hundred
times more useful to me if I could, using some sort of Postgres function
or conversion operator, take the output of the age function, which is
returned as type 'timespan' and condense that into just 'days' or
'months'.
In other words, when I do this:
database => select age('now', '09-01-1998'::datetime);
Instead of it telling me this:
age
---------------------------------------
@ 2 mons 4 days 6 hours 40 mins 47 secs
I would like to be able to make it tell me:
age
---------
66.3 days
or something to that effect.
Is there a way I can do this? At first, I tried the date_part function,
but (for obvious reasons) it didn't do what I thought it was doing.
Please let me know,
Bob
On 05-Nov-98 Bob Dusek wrote:
Hello again,
I am using the age() function to determine the average shelf-life of
Where is this age function ?
When I do \df i can't find it anywhere? Using pg 6.3
Mario Filipe
mjnf@uevora.pt
-----> http://neptuno.sc.uevora.pt/~mjnf <-----
On 05-Nov-98 Bob Dusek wrote:
Hello again,
I am using the age() function to determine the average shelf-life of
Where is this age function ?
When I do \df i can't find it anywhere? Using pg 6.3
Mario Filipe
mjnf@uevora.pt
-----> http://neptuno.sc.uevora.pt/~mjnf <----- << File: ATT01281.ATT
Look in the set of functions returning timespan.
In v6.4 you can just do '\df age'.
-DEJ
Import Notes
Resolved by subject fallback
Here's where I found it:
http://www.postgresql.org/docs/user/functions2145.htm
If you would happen to know how to convert a 'timespan' to seconds, or
minutes, or days, or weeks, or months... etc. please let me know.
Bob
Mario Filipe wrote:
Show quoted text
On 05-Nov-98 Bob Dusek wrote:
Hello again,
I am using the age() function to determine the average shelf-life of
Where is this age function ?
When I do \df i can't find it anywhere? Using pg 6.3
Mario Filipe
mjnf@uevora.pt
-----> http://neptuno.sc.uevora.pt/~mjnf <-----------------------------------------------------------------------------
Part 1.2Type: application/pgp-signature