Re: Time functions

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: "Ron St(dot)Pierre" <rstpierre(at)syscor(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Time functions
Date: 2002-12-10 17:23:44
Message-ID: 20021210172344.E00E1103C2@polaris.pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How about:

select userID,
sum((abstime(endTimeStamp)-abstime(startTimeStamp))::numeric)/3600 as
totalhours from yourLogTable group by userID;

Cheers,
Steve

On Monday 09 December 2002 4:00 pm, Ron St.Pierre wrote:
> Hi, I've got another question about time - timestamps. I need to
> summarize the amount of time a user has used the system for from a table
> listing the userID, startTimestamp, endTimestamp.
> id userID startTimestamp endTimestamp
> 1 2119 5/10/00 7:32:33 PM 5/10/00 7:33:59 PM
> 2 2119 5/10/00 7:36:30 PM 5/10/00 7:39:27 PM
> 3 2119 5/10/00 7:40:01 PM 5/10/00 9:40:05 PM
> 4 2120 5/10/00 8:11:12 PM 5/10/00 8:11:21 PM
> 5 2121 5/10/00 8:12:26 PM 5/10/00 8:12:46 PM
>
> I don't want to use the interval functions as I don't want the results
> summarized by total months, weeks, days, years, hours, minutes,
> seconds...., I just want the total hours eg 47.98 HOURS
> I couldn't find any suitable way of doing it in the manual or in
> techdocs(.postgresq.org).
>
> Anyone have any suggestions?
> Thanks

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Al Sutton 2002-12-10 17:25:30 Re: [mail] Re: 7.4 Wishlist
Previous Message Jim Martinez 2002-12-10 16:58:30 createlang plpgsql error