Re: Understanding PGInterval - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Understanding PGInterval
Date
Msg-id Pine.BSO.4.64.0903220010250.17095@leary.csoft.net
Whole thread Raw
In response to Understanding PGInterval  ("r.trommer@open-factory.org" <r.trommer@googlemail.com>)
List pgsql-jdbc

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

pgsql-jdbc by date:

Previous
From: "r.trommer@open-factory.org"
Date:
Subject: Understanding PGInterval
Next
From: Maciek Sakrejda
Date:
Subject: Test suite failures?