Re: Re: Get the difference between two timestamp cells but in a special format in PostgreSQL

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Re: Get the difference between two timestamp cells but in a special format in PostgreSQL
Дата
Msg-id 558D9175.30903@aklaver.com
обсуждение исходный текст
Ответ на Re: Get the difference between two timestamp cells but in a special format in PostgreSQL  (litu16 <litumelendez@gmail.com>)
Ответы Re: Re: Get the difference between two timestamp cells but in a special format in PostgreSQL  (Colin Lieberman <clieberman@turnitin.com>)
Список pgsql-general
On 06/25/2015 08:23 PM, litu16 wrote:
> Hi Adrian,
>
> but I would like to get the time diff in this format
>
> 0years 0months 0days 00:00:00.000
>
> not only hours, minutes, seconds.
>
> is this possible???

Well age:

http://www.postgresql.org/docs/9.4/interactive/functions-datetime.html

does that sort of:

production=# SELECT age(timestamp '2015-06-26 09:15:15', timestamp
'2015-06-26 02:16:00');
    age
----------
  06:59:15
(1 row)

production=# SELECT age(timestamp '2015-06-26 09:15:15', timestamp
'2015-06-20 02:16:00');
        age
-----------------
  6 days 06:59:15
(1 row)

production=# SELECT age(timestamp '2015-06-26 09:15:15', timestamp
'2014-06-20 02:16:00');
           age
------------------------
  1 year 6 days 06:59:15
(1 row)





>
> Thanks Advanced.
>
>
>
> --
> View this message in context:
http://postgresql.nabble.com/Get-the-difference-between-two-timestamp-cells-but-in-a-special-format-in-PostgreSQL-tp5855074p5855215.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


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

Предыдущее
От: Tim Smith
Дата:
Сообщение: Re: Functions, savepoints, autocommit = I am confused !
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Functions, savepoints, autocommit = I am confused !