Re: Understanding PGInterval

From: Kris Jurka <books(at)ejurka(dot)com>
To: "r(dot)trommer(at)open-factory(dot)org" <r(dot)trommer(at)googlemail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Understanding PGInterval
Date: 2009-03-22 04:12:46
Message-ID: Pine.BSO.4.64.0903220010250.17095@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Sat, 21 Mar 2009, r(dot)trommer(at)open-factory(dot)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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Maciek Sakrejda 2009-03-23 16:12:08 Test suite failures?
Previous Message r.trommer@open-factory.org 2009-03-21 23:06:56 Understanding PGInterval