Re: [psycopg] Using infinite values with DateTimeTZRange

Поиск
Список
Период
Сортировка
От Fennell, Felix W.
Тема Re: [psycopg] Using infinite values with DateTimeTZRange
Дата
Msg-id AM3PR06MB1442FBEDDFC0F0CCA14C32DA9C850@AM3PR06MB1442.eurprd06.prod.outlook.com
обсуждение исходный текст
Ответ на [psycopg] Using infinite values with DateTimeTZRange  ("Fennell, Felix W." <felnne@bas.ac.uk>)
Ответы Re: [psycopg] Using infinite values with DateTimeTZRange  (Jonathan Rogers <jrogers@emphasys-software.com>)
Список 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
itjust 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@postgresql.org <psycopg-owner@postgresql.org> on behalf of Jonathan Rogers
<jrogers@emphasys-software.com>
Sent: 22 August 2017 16:19
To: psycopg@postgresql.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’
datesusing 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@emphasys-software.com
________________________________
 This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000
andthe contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under
theAct. Any material supplied to NERC may be stored in an electronic records management system. 
________________________________


В списке psycopg по дате отправления:

Предыдущее
От: "Fennell, Felix W."
Дата:
Сообщение: Re: [psycopg] Using infinite values with DateTimeTZRange
Следующее
От: Jonathan Rogers
Дата:
Сообщение: Re: [psycopg] Using infinite values with DateTimeTZRange