Re: Converting seconds past midnight to a time

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Converting seconds past midnight to a time
Date: 2005-12-18 04:26:25
Message-ID: 13109.1134879985@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

"Karl O. Pinc" <kop(at)meme(dot)com> writes:
> What is the best way to convert an integer number of
> seconds past midnight into a time?

Intermediate 'interval' value seems to work:

regression=# select (99.44 * '1 second'::interval)::time;
time
-------------
00:01:39.44
(1 row)

> On a related note is there some reason why
> interval + int
> does not result in the interval plus int number
> of seconds?

Again, multiplying the number by '1 sec'::interval would get you there.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karl O. Pinc 2005-12-18 04:35:26 Re: DBlink documentation
Previous Message Karl O. Pinc 2005-12-18 04:25:05 Converting seconds past midnight to a time

Browse pgsql-patches by date

  From Date Subject
Next Message Karl O. Pinc 2005-12-18 07:29:45 Re: Converting seconds past midnight to a time
Previous Message Karl O. Pinc 2005-12-18 04:25:05 Converting seconds past midnight to a time