Re: Convert time to millisec? - Mailing list pgsql-general

From Bjørn T Johansen
Subject Re: Convert time to millisec?
Date
Msg-id 20060828161812.55124773@pennywise
Whole thread Raw
In response to Re: Convert time to millisec?  (Michael Fuhr <mike@fuhr.org>)
Responses Re: Convert time to millisec?
List pgsql-general
On Mon, 28 Aug 2006 07:20:02 -0600
Michael Fuhr <mike@fuhr.org> wrote:

> On Mon, Aug 28, 2006 at 10:48:47AM +0200, Bjørn T Johansen wrote:
> > select sum(Til - Fra) as total from Log_stop where OrdreID = 3434
> >
> > but I would like the result to be in milliseconds, is this possible? If so, how?
> > (the fields Til and Fra is of type Time)
>
> You could use extract(epoch from <interval>) to get the number of
> seconds (with fractional part) in an interval, then multiply by
> 1000 to get milliseconds.  Example:
>
> select extract(epoch from sum(Til - Fra)) * 1000.0 ...
>

That did the trick... Thx... :)

Do you know if this is supported on older versions of PostgreSQL as well? (eg. 7.4.x)


BTJ

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Perl language creation failed
Next
From: Michael Fuhr
Date:
Subject: Re: Convert time to millisec?