Re: now() vs 'epoch'::timestamp

From: James Cloos <cloos(at)jhcloos(dot)com>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general\(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: now() vs 'epoch'::timestamp
Date: 2015-04-02 18:33:48
Message-ID: m3vbhecrcj.fsf@carbon.jhcloos.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "SC" == Steve Crawford <scrawford(at)pinpointresearch(dot)com> writes:

SC> select (now() - (now() - 'epoch')) ;
SC> ?column?
SC> ------------------------
SC> 1969-12-31 17:00:00-08

My servers all run in UTC, so that query works here.

The first query where I noticed this, I had just run date +%s and used
that value in now() - 1427998368::reltime, like:

One term:
:; date +%s
1427998617

Other term:

cloos=# select now() - 1427998617::reltime;
?column?
-------------------------------
1970-01-01 06:00:03.137866+00

(As you can see it took me 3 seconds to do the copy-paste...:)

For now()-'epoch' I get the format:

16527 days 18:27:01.688195

but for 1427999266::reltime I get:

45 years 3 mons 1 day 12:27:46

I wonder whether the YMD to D conversion takes into account the actual
number of Bissextile years?

If so, I guess that is another nail in reltime's coffin.

now() - to_timestamp(1427999266) worked correctly, but that is not
unexpected given to_timestamp's definition.

-JimC
--
James Cloos <cloos(at)jhcloos(dot)com> OpenPGP: 0x997A9F17ED7DAEA6

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vu Nguyen 2015-04-02 19:10:39 bdr global sequence not initialized
Previous Message James Cloos 2015-04-02 18:14:14 Re: now() vs 'epoch'::timestamp