Обсуждение: interval related problem

Поиск
Список
Период
Сортировка

interval related problem

От
Rakesh Shembekar
Дата:
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


Do you Yahoo!?
Meet the all-new My Yahoo! � Try it today!

Re: interval related problem

От
Kris Jurka
Дата:

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