Re: Converting seconds past midnight to a time

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: Michael Glaesemann <grzm(at)myrealbox(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Converting seconds past midnight to a time
Date: 2005-12-19 22:11:09
Message-ID: 20051219221109.GQ28771@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

On Sun, Dec 18, 2005 at 07:29:45AM +0000, Karl O. Pinc wrote:
>
> On 12/17/2005 10:21:39 PM, Michael Glaesemann wrote:
> >
> >On Dec 18, 2005, at 13:25 , Karl O. Pinc wrote:
> >>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.
>
> Good question. I guess it's because I couldn't corece
> an int into an interval number of seconds. ;-) But if it was to be
> anything it should be seconds or milliseconds as those
> are the only ones that make the math easy, in the sense of
> working with whole numbers.

Well, generally speaking people work with time either in some native
format (ie: timestamp) or as a number of seconds. I don't think there's
enough consistency between time being a number of milliseconds or
microseconds to warrant that.

Personally, I don't think it would be unreasonable to allow timestamp +
int and timestamp + double (with int and double being treated as
seconds). I don't recall ever seeing an email on the lists from someone
expecting time/timestamp + bare number to mean 'add X hours' or 'add X
fractional seconds', but people do ask about adding X seconds pretty
often.

Another option would be creating a set of timestamp math functions; that
would probably help cut down on the number of questions about this.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2005-12-19 22:12:34 Re: update count
Previous Message Jim C. Nasby 2005-12-19 21:55:38 Re: [Pgsqlrpms-hackers] Re: DBlink documentation

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-12-19 22:59:12 Re: Trouble building 8.1.1 on Tru64 UNIX 5.1
Previous Message Albert Chin 2005-12-19 21:58:54 Trouble building 8.1.1 on Tru64 UNIX 5.1