From: Michael Fuhr <mike@fuhr.org>
To: Jamison Roberts <jamisonroberts@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Formatting an Interval
Date: Fri, 31 Dec 2004 12:41:18 -0700
Message-ID: <20041231194118.GA23987@winnie.fuhr.org> (raw)
In-Reply-To: <238e52230412310837183fb730@mail.gmail.com>
References: <238e52230412310837183fb730@mail.gmail.com>
On Fri, Dec 31, 2004 at 11:37:32AM -0500, Jamison Roberts wrote:
> All of the functions that i've looked at seem to only extract parts
> from Intervals. What I need to do is to format the interval. For
> instance, I have a Interval with the value 1 day 07:57:52. I would
> like that in HH:MM:SS. So in the example the output would be
> 31:57:52.
I'm not aware of a built-in way to get such a format; somebody
please correct me if I'm mistaken.
You could write a function to format the interval. For example,
with PL/pgSQL you could use EXTRACT(epoch FROM interval_value) to
convert the interval to a number of seconds; convert that to hours,
minutes, and seconds; and use TO_CHAR to format the return value.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mike@fuhr.org, jamisonroberts@gmail.com
Subject: Re: Formatting an Interval
In-Reply-To: <20041231194118.GA23987@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox