Re: BUG #4972: RFE: convert timestamps to fractional seconds

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Neill <rn214(at)cam(dot)ac(dot)uk>
Cc: pgsql-bugs(at)postgresql(dot)org, peter_e(at)gmx(dot)net
Subject: Re: BUG #4972: RFE: convert timestamps to fractional seconds
Date: 2009-08-10 15:15:42
Message-ID: 2360.1249917342@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Richard Neill <rn214(at)cam(dot)ac(dot)uk> writes:
> (b) Nowhere on the page is there a full example for getting
> seconds+microseconds since the epoch

Yeah, we could change that example to include a fractional part in the
timestamp to make this clearer.

> What I think I meant was dividing a differential timestamp by an
> interval. In this case, both should be unambiguously expressed in
> seconds, and the result will be dimensionless.

What you're missing is that intervals are not single numbers, and
are not simply numbers of seconds.

> Do you agree that an explicit cast of a timestamp to a double should work?

Doesn't seem like a particularly good idea. You're free to add such
a cast to your own DBs, of course.

> Do you agree that abs() should be able to operate on an interval?
> select abs( interval '-1 week');

It's not as easy as that, because (once again) intervals aren't single
numbers. For example, what should become of
abs(interval '-1 month +1 day')
The negative of this would be '1 month -1 day'. It's not real clear to
me whether abs() should give that or '1 month 1 day', ie, make all the
fields positive independently.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Hiroshi Saito 2009-08-10 16:19:40 Re: BUG #4961: pg_standby.exe crashes with no args
Previous Message Tom Lane 2009-08-10 15:10:02 Re: Huge speed penalty using <>TRUE instead of =FALSE