Re: Converting seconds past midnight to a time - Mailing list pgsql-general

From Michael Glaesemann
Subject Re: Converting seconds past midnight to a time
Date
Msg-id 91469550-69FF-48DF-8A9C-0C3012A10371@myrealbox.com
Whole thread Raw
In response to Converting seconds past midnight to a time  ("Karl O. Pinc" <kop@meme.com>)
Responses Re: Converting seconds past midnight to a time  ("Karl O. Pinc" <kop@meme.com>)
List pgsql-general
On Dec 18, 2005, at 13:25 , Karl O. Pinc wrote:

> What is the best way to convert an integer number of
> seconds past midnight into a time?

Try your_date::timestamptz + your_seconds * interval '1 sec', e.g.,

test=# select current_date::timestamptz, current_date::timestamptz +
1000 * interval '1 sec';
       timestamptz       |        ?column?
------------------------+------------------------
2005-12-18 00:00:00+09 | 2005-12-18 00:16:40+09
(1 row)

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

Why should the int necessarily represent seconds and not some other
amount of time? It's just a unit-less value.

Michael Glaesemann
grzm myrealbox com




pgsql-general by date:

Previous
From: "Karl O. Pinc"
Date:
Subject: Re: DBlink documentation
Next
From: Tom Lane
Date:
Subject: Re: Converting seconds past midnight to a time