Re: Sum(time) possible?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: elwood(at)agouros(dot)de (Konstantinos Agouros)
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Sum(time) possible?
Date: 2001-11-03 18:10:02
Message-ID: 2528.1004811002@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

elwood(at)agouros(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Domingo Alvarez Duarte 2001-11-03 18:16:55 Re: Porting Web application written in Oracle 8 PL/SQL to Postgresql
Previous Message cbbrowne 2001-11-03 18:05:43 Re: Sum(time) possible?