Re: Sum(time) possible? - Mailing list pgsql-general

From Tom Lane
Subject Re: Sum(time) possible?
Date
Msg-id 2528.1004811002@sss.pgh.pa.us
Whole thread Raw
In response to Sum(time) possible?  (elwood@agouros.de (Konstantinos Agouros))
List pgsql-general
elwood@agouros.de (Konstantinos Agouros) writes:
> I have a column of times that I would need to sum up for accounting purposes.
> Since sum(time) does not seem to be defined anybody got an easy clue how to
> do this?

We don't have addition of times defined at all, so how would you expect
sum() to exist?  Try casting the times to some datatype for which
addition makes sense, eg interval.

The reason time addition isn't defined is that it's not clear what
people would want.  Is '9:12 PM' + '4:23 AM' even sensible?  If
so, does it mean '1:35 AM' or '1 day 1 hour 35 minutes'?  Casting
to interval makes clear that you want the latter interpretation.

            regards, tom lane

pgsql-general by date:

Previous
From: Kenneth Skiles
Date:
Subject: trigger call shell script
Next
From: "Command Prompt, Inc."
Date:
Subject: Re: Sum(time) possible?