RE: MySQL-esque sec_to_time() function

Поиск
Список
Период
Сортировка
От Francis Solomon
Тема RE: MySQL-esque sec_to_time() function
Дата
Msg-id NEBBIFFPELJMCJAODNPKMEJMCDAA.francis@stellison.co.uk
обсуждение исходный текст
Ответ на MySQL-esque sec_to_time() function  ("George Johnson" <gjohnson@jdsc.com>)
Список pgsql-general
Hi George,

Difference of two timestamps directly :

dbtest=# select 'now'::timestamp - '2000-12-06 13:47:57+00'::timestamp
as "Time Interval";
 Time Interval
---------------
 02:49:34
(1 row)

Number of seconds converted to hh:mm:ss :

dbtest=# select '12345 seconds'::interval as "Time Interval";
 Time Interval
---------------
 03:25:45
(1 row)

Hope this helps

Francis Solomon

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of George Johnson
Sent: 06 December 2000 16:28
To: pgsql-general@postgresql.org
Subject: [GENERAL] MySQL-esque sec_to_time() function


Hello,

I'm converting from MySQL to PostgreSQL (actually flipping/flopping
back) and have a question:


MySQL has a cool function sec_to_time() which converts your number of
seconds to hh:mm:ss

I've read thru the mailing lists and am basically trying to implement
the following:


MySQL:
select sec_to_time(sum(unix_timestamp(enddate) -
unix_timestamp(startdate))) from foo;

PostgreSQL:
select XXX(sum(date_part('epoch',enddate) -
date_part('epoch',startdate))) from foo;

I just need to know what XXX is/can be.  I've tried a lot of
combinations of the documented functions and come up with useless
conversions.

Thanks,
George Johnson
gjohnson@jdsc.com

PS:  i can't find documentation on how to load the functions in contrib.
I can compile and
       install them O.K., but not sure how to make them load.


В списке pgsql-general по дате отправления:

Предыдущее
От: Isaac
Дата:
Сообщение: localization design for DB structures?
Следующее
От: "George Johnson"
Дата:
Сообщение: apache .htaccess / postgresql module