|Subject||RE: [firebird-support] sum and time fields|
> Hi all,So you have a field called DURATION and it's of type TIMESTAMP? Is that
> I don't know if this is the right place to ask the following question.
> Sorry if it's not.
> I'd like to add time fields, something like :
> select phone_number, sum(duration)
> from phone_calls
> group by phone_number
> where ...
We've seen this discussion many times and there is a hefty set of threads to
search on this list.
The short story for you though, is that TIMESTAMP fields contain TIME, not
duration in seconds. TIMESTAMP fields start at midnight and end just before
You need to record your start and stop events, then update an integer field
with the difference between the two. You can then sum that field.
If you're interested in duration in seconds then you need to convert the
fractional part of this difference to seconds. If you're interested in a
duration in days, then the integer part of the difference is all you need to
> Of course, Firebird doesn't like this. How is it possible to do ?
> Many thanks in advance.