Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "SC" == Steve Crawford <scrawford@xxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxx>         OpenPGP: 0x997A9F17ED7DAEA6


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux