pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Bryn Llewellyn <bryn@yugabyte.com>
To: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Using make_timestamp() to create a BC value
Date: Wed, 6 Oct 2021 15:26:17 -0700
Message-ID: <971fc235-135e-3d11-9ae2-df4ff14c6d2a@aklaver.com> (raw)
In-Reply-To: <010C91D3-9982-445D-B3C1-B20BD1E8C841@yugabyte.com>
References: <010C91D3-9982-445D-B3C1-B20BD1E8C841@yugabyte.com>

On 10/6/21 2:59 PM, Bryn Llewellyn wrote:
> Everything that I say here applies to "make_timestamptz()", too. But my 
> code examples need less typing when I use plain "make_timestamp()".
> 

> (And sure enough, "raise info 'year: %', year" reports "-1".)
> 
> The doc for "make_timestamp()" here:
> 
>     www.postgresql.org/docs/14/functions-datetime.html
>     <http://www.postgresql.org/docs/14/functions-datetime.html;
> 

What version of Postgres are you using?

Postgres 13:

select extract(year from '0001-01-01 00:00:00 BC'::timestamp);
  date_part
-----------
         -1

select make_timestamp(-1,1,1,2,30,0);
ERROR:  date field value out of range: -1-01-01


Postgres 14:

select extract(year from '0001-01-01 00:00:00 BC'::timestamp);
  date_part
-----------
         -1

select make_timestamp(-1,1,1,2,30,0);
      make_timestamp
------------------------
  0001-01-01 02:30:00 BC

Postgres release notes


https://www.postgresql.org/docs/current/release-14.html#id-1.11.6.5.3

Allow make_timestamp()/make_timestamptz() to accept negative years 
(Peter Eisentraut)

Negative values are interpreted as BC years.



-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (4+ messages)  latest in thread

Message-ID: <971fc235-135e-3d11-9ae2-df4ff14c6d2a@aklaver.com>
Permalink:  ../971fc235-135e-3d11-9ae2-df4ff14c6d2a@aklaver.com/
Also on:    postgresql.org/message-id/971fc235-135e-3d11-9ae2-df4ff14c6d2a@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, bryn@yugabyte.com
  Subject: Re: Using make_timestamp() to create a BC value
  In-Reply-To: <971fc235-135e-3d11-9ae2-df4ff14c6d2a@aklaver.com>
  References: <010C91D3-9982-445D-B3C1-B20BD1E8C841@yugabyte.com> <971fc235-135e-3d11-9ae2-df4ff14c6d2a@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox