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