Re: Using infinite values with DateTimeTZRange

From: Jonathan Rogers <jrogers(at)emphasys-software(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Re: Using infinite values with DateTimeTZRange
Date: 2017-08-22 15:19:37
Message-ID: c5cdbfa7-d640-4640-d9f1-0ec3ca25d773@emphasys-software.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On 08/20/2017 10:23 AM, Fennell, Felix W. wrote:
> Hi,
>
> Apologies if this isn’t the right place to ask questions like this but I am having difficulty storing ‘infinite’ dates using the DateTimeTZRange object.
>
> I have a Postgres database with a ‘tstzrange’ column (named validity) and I’d like to store a value in this similar to ‘[“2010-01-01 10:00:00 +01”, infinity]’.

While it is not an error to use 'infinity' or '-infinity' in a
tstzrange, since those are acceptable timestamptz values, that is not
the normal way to represent a range which extends infinitely in one
direction. The normal way to represent a range with an infinite upper or
lower bound is to omit the bound, as in '["2010-01-01 10:00:00 +01",]'.

Read the manual for more detail:

https://www.postgresql.org/docs/current/static/rangetypes.html#RANGETYPES-INFINITE

--
Jonathan Rogers
Socialserve.com by Emphasys Software
jrogers(at)emphasys-software(dot)com

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Fennell, Felix W. 2017-08-23 22:04:41 Re: Using infinite values with DateTimeTZRange
Previous Message Aryeh Leib Taurog 2017-08-22 12:43:00 pgcopy 1.3.0 release announcement