Re: format return of "age" to hh:mm

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: format return of "age" to hh:mm
Дата
Msg-id CAKFQuwZxKkQZtxwu0i5jGp6aEU2B8SEkav9LweRKSwX9i6hUVA@mail.gmail.com
обсуждение исходный текст
Ответ на format return of "age" to hh:mm  (David Gauthier <davegauthierpg@gmail.com>)
Список pgsql-general
On Thu, Mar 5, 2020 at 8:50 AM David Gauthier <davegauthierpg@gmail.com> wrote: 
Hi:

How does one reformat the output of the "age" function to always be in terms of hours:mins.



Custom function.

Use justify_hours(interval) to normalize the input in terms of days
Use extract(field from interval) to get the components, including days
Multiply the days result by 24, add it to the hours result
Deal with fractional hours
Combine and return

There is no justify_minutes function unfortunately which, if implemented to the behavior of justify_hours, would do what you are looking for.  You basically want to write one, though I suspect in SQL instead of C.

David J.

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

Предыдущее
От: Andrei Zhidenkov
Дата:
Сообщение: Re: format return of "age" to hh:mm
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: format return of "age" to hh:mm