public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laura Smith <[email protected]>
To: postgre <[email protected]>
Subject: Re: How to update upper-bound of tstzrange ?
Date: Tue, 21 May 2024 10:37:18 +0000
Message-ID: <Y-dgBIo8uwhiTSzCxmbuJum0cbMXiT9UhvKogFAS34MkcXr_MUGHchf1WZEzWTLtg7gtp8A2HlyLFVME-Y4ID4ZLwRFwnE3VYhAybvEhFCw=@protonmail.ch> (raw)
In-Reply-To: <[email protected]>
References: <dwdB2YsSerbqrnxCL0GdRg7C61LmqBs4V-7-qC7t9sAq7_MY6Y76tQ4rhwHKbvJRr-6We87i_r0KHwDaf3yoxBbld1-62IPNoiZ3rtBGW8Q=@protonmail.ch>
	<[email protected]>
	<[email protected]>

Thanks all for your answers !  Much appreciated.




Sent with Proton Mail secure email.

On Tuesday, 21 May 2024 at 11:02, Laurenz Albe <[email protected]> wrote:

> On Mon, 2024-05-20 at 13:56 +0200, Erik Wienhold wrote:
> 
> > On 2024-05-20 12:30 +0200, Laura Smith wrote:
> > 
> > > Could someone kindly help me out with the correct syntax ?
> > > 
> > > My first thought was the below but that doesn't work:
> > > 
> > > update foo set upper(bar_times)=upper(bar_times)+interval '1' hour where bar_id='abc';
> > > ERROR: syntax error at or near "("
> > > LINE 1: update event_sessions set upper(bar_times)=upper(bar_ti...
> > 
> > Use the constructor function:
> > 
> > UPDATE foo SET bar_times = tstzrange(lower(bar_times), upper(bar_times) + interval '1' hour);
> > 
> > But this does not preserve the inclusivity/exclusivity of bounds from
> > the input range, so you may have to pass in the third argument as well.
> > 
> > https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-CONSTRUCT
> 
> 
> If you need to preserve the information whether the upper and lower bounds
> are inclusive or not, you could
> 
> UPDATE foo
> SET bar_times = tstzrange(
> lower(bar_times),
> upper (bar_times) + INTERVAL '1 hour',
> CASE WHEN lower_inc(bar_times) THEN '[' ELSE '(' END ||
> CASE WHEN upper_inc(bar_times) THEN ']' ELSE ')' END
> )
> WHERE ...
> 
> Yours,
> Laurenz Albe






view thread (3+ messages)

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: How to update upper-bound of tstzrange ?
  In-Reply-To: <Y-dgBIo8uwhiTSzCxmbuJum0cbMXiT9UhvKogFAS34MkcXr_MUGHchf1WZEzWTLtg7gtp8A2HlyLFVME-Y4ID4ZLwRFwnE3VYhAybvEhFCw=@protonmail.ch>

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

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