Define maximum time increment.

Started by Joshua Moore-Olivaabout 23 years ago1 messagesgeneral
Jump to latest
#1Joshua Moore-Oliva
josh@chatgris.com

I am attempting to extract the number of months, or sometimes minutes from an
interwith with age for example.

SELECT age(timestamp '1957-06-13 10:57');

returns "45 years 8 mons 24 days 13:03"

while

SELECT EXTRACT (minutes FROM age(timestamp '1957-06-13 10:57') );

returns just "3"

Is there a way to define per session the MAXIMUM time increment for an
interval? So that It would return the total number of minutes since that
date?

Basically, I think should could be achieved by some sort of interval
formatting functions... something along the lines of

SELECT EXTRACT (minutes FROM ( age(timestamp '1957-06-13 10:57') LIMIT minutes
) );

I really need this functionality for a number of examples just no the minutes.
I know i could extract epoch, divide by 60 and I'm fine. But I also needs
months... then I need to extracts months plus years * 12.. I also have a
need for days... then that gets even messier...

Any hints or even vague ideas are very welcome!

Josh.