Re: interval related problem - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: interval related problem
Date
Msg-id Pine.BSO.4.56.0412232300100.5322@leary.csoft.net
Whole thread Raw
In response to interval related problem  (Rakesh Shembekar <srakesh_22@yahoo.com>)
List pgsql-jdbc

On Thu, 23 Dec 2004, Rakesh Shembekar wrote:

> I am firing a query some thing like this select ('2004-12-12'::time -
> '2004-10-12'::time) from employee; Which returs me time in days I want
> time in hours and minutes what I should do With anticipatory thanks
>

This question has nothing to do with Java or JDBC so it is not really
appropriate for this list.  I suggest you try pgsql-general@postgresql.org
instead.

Your example clearly isn't right because:

=# select ('2004-12-12'::time - '2004-10-12'::time);
ERROR:  invalid input syntax for type time: "2004-12-12"

If you are really casting to a date then date subtraction does give an
integer.  If you are casting to a timestamp then subtraction gives you an
interval.  Conversion from either of these forms to hours and minutes will
require some doing on your part.  You might investigae the extract
command:

http://www.postgresql.org/docs/7.4/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT

Kris Jurka

pgsql-jdbc by date:

Previous
From: Rakesh Shembekar
Date:
Subject: interval related problem
Next
From: "Xavier Poinsard"
Date:
Subject: Update french .po