Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] Converting seconds past midnight to a time

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Karl O(dot) Pinc" <kop(at)meme(dot)com>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [GENERAL] Converting seconds past midnight to a time
Date: 2005-12-21 16:04:34
Message-ID: 200512211604.jBLG4Yn28745@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-patches
Tom Lane wrote:
> "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.

I have applied the following documentation patch to HEAD and 8.1.X.
It is unified diff because those are easier with single-line changes
like this, where the surrounding text isn't as significant.

I also fixed an example '1 day' - '1 hour' which now computes
differently, and added trailing zero seconds, which is our display
default.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

pgsql-patches by date

Next:From: Simon RiggsDate: 2005-12-21 16:23:52
Subject: Re: COPY LOCK for WAL bypass
Previous:From: Bruce MomjianDate: 2005-12-21 13:18:15
Subject: Re: COPY LOCK for WAL bypass

pgsql-general by date

Next:From: Jerry LeVanDate: 2005-12-21 19:12:43
Subject: Funky template1 problem?
Previous:From: Seneca CunninghamDate: 2005-12-21 15:48:03
Subject: Re: out of memory during query execution

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group