pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Rakesh Shembekar <srakesh_22@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: interval related problem
Date: Thu, 23 Dec 2004 23:06:06 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0412232300100.5322@leary.csoft.net> (raw)
In-Reply-To: <20041224033700.94987.qmail@web14307.mail.yahoo.com>
References: <20041224033700.94987.qmail@web14307.mail.yahoo.com>



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



view thread (2+ messages)

Message-ID: <Pine.BSO.4.56.0412232300100.5322@leary.csoft.net>
Permalink:  ../Pine.BSO.4.56.0412232300100.5322@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.56.0412232300100.5322@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, srakesh_22@yahoo.com
  Subject: Re: interval related problem
  In-Reply-To: <Pine.BSO.4.56.0412232300100.5322@leary.csoft.net>
  References: <20041224033700.94987.qmail@web14307.mail.yahoo.com> <Pine.BSO.4.56.0412232300100.5322@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox