Understanding PGInterval
Understanding PGInterval
От:
"r.trommer@open-factory.org" <r.trommer@googlemail.com>
Дата:
Hello List, i try to understand how i can use the PGInterval Object. I have to solve a little issue in Java. I have created a SQL-statement which give me a resultset like this: id | duration 1 | 01:49:00 2 | 00:30:00 The datetypes id = int and duration = PGInterval. I would like to sum the both duration values in Java. I can´t use a SQL sum because i need the results later to report some details. I use postgresql-8.1-404.jdbc2.jar Thank you in advance Ronny
Re: Understanding PGInterval
От:
Kris Jurka <books@ejurka.com>
Дата:
On Sat, 21 Mar 2009, r.trommer@open-factory.org wrote: > i try to understand how i can use the PGInterval Object. I have to > solve a little issue in Java. I have created a SQL-statement which > give me a resultset like this: > > id | duration > 1 | 01:49:00 > 2 | 00:30:00 > > The datetypes id = int and duration = PGInterval. I would like to sum > the both duration values in Java. I can´t use a SQL sum because i need > the results later to report some details. > The 8.3 driver series has an enhancement to PGInterval which supports adding them together. So you can do interval1.add(interval2) to sum things up. What it doesn't support is justifying the results, so in the example you've shown above the total would be 1 hour, 79 minutes rather than 2 hours and 19 minutes. Kris Jurka