From: | "Fennell, Felix W(dot)" <felnne(at)bas(dot)ac(dot)uk> |
---|---|
To: | Jonathan Rogers <jrogers(at)emphasys-software(dot)com>, "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org> |
Subject: | Re: Using infinite values with DateTimeTZRange |
Date: | 2017-08-23 22:14:08 |
Message-ID: | AM3PR06MB1442FBEDDFC0F0CCA14C32DA9C850@AM3PR06MB1442.eurprd06.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
> 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",]'.
Thanks for that - in my case I want to distinguish between cases where the end-date for a range is not known, and where it just been considered yet. The latter case I'm representing as a date-range without an upper bound, so thought 'infinity' was the best choice for where the end-date had been considered, but is unknown.
Hope that reasoning makes sense, and if there's a better way to represent those two states then I'd be open to changing that.
-- Felix
__________________________________
From: psycopg-owner(at)postgresql(dot)org <psycopg-owner(at)postgresql(dot)org> on behalf of Jonathan Rogers <jrogers(at)emphasys-software(dot)com>
Sent: 22 August 2017 16:19
To: psycopg(at)postgresql(dot)org
Subject: Re: [psycopg] Using infinite values with DateTimeTZRange
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
________________________________
This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system.
________________________________
From | Date | Subject | |
---|---|---|---|
Next Message | Jonathan Rogers | 2017-08-23 22:30:36 | Re: Using infinite values with DateTimeTZRange |
Previous Message | Fennell, Felix W. | 2017-08-23 22:04:41 | Re: Using infinite values with DateTimeTZRange |