Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9Ms6-001lnc-6E for pgsql-general@arkaria.postgresql.org; Tue, 21 May 2024 10:37:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s9Ms5-0095ix-Tv for pgsql-general@arkaria.postgresql.org; Tue, 21 May 2024 10:37:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9Ms5-0095fb-Gk for pgsql-general@lists.postgresql.org; Tue, 21 May 2024 10:37:29 +0000 Received: from mail-4316.protonmail.ch ([185.70.43.16]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s9Ms2-001H4B-3t for pgsql-general@lists.postgresql.org; Tue, 21 May 2024 10:37:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.ch; s=protonmail3; t=1716287842; x=1716547042; bh=TIoFZr3yhCTC9Ki4FxQ7JVotQHqiBksLg3sO2SgamK4=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=YIppPj+twGw9JWlhgQUi33bdb/f2hIqic5nlid4/ZmSJUqeeTqk0p5I82aJ7HHAnj QBb2zITgTrMIHMWckliJ4Uq+Q5N1skFWYJ2UfrZaSYOq8FzfwcOYyTkfR1BozkOfs1 LWgK59vpQ9NZQ8XXmrVH1z/CAtuqQVt3NZboOOhXXoV9QgbHXPHcMYISjLb2oYN+56 B5Uqi8SLxEVQwjh+CF76ZWIJrubR4J2bLIet0m/tjIQeVyBkhUR5+tcCeGYn50WZuf afUV4PunQSV4Pelf+KDR2qabqvFXxKsZOpEDV3sePZGoE556D+k81k50wmFw76V7r0 Z4/jwracOA7/g== Date: Tue, 21 May 2024 10:37:18 +0000 To: postgre From: Laura Smith Subject: Re: How to update upper-bound of tstzrange ? Message-ID: In-Reply-To: <82f02004dc5fd734c925d4db0c48190e8100a42d.camel@cybertec.at> References: <82f02004dc5fd734c925d4db0c48190e8100a42d.camel@cybertec.at> Feedback-ID: 9341368:user:proton X-Pm-Message-ID: a45ac33d1cb09994dc13be7abe7aecd09d828ca5 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks all for your answers ! Much appreciated. Sent with Proton Mail secure email. On Tuesday, 21 May 2024 at 11:02, Laurenz Albe w= rote: > On Mon, 2024-05-20 at 13:56 +0200, Erik Wienhold wrote: >=20 > > On 2024-05-20 12:30 +0200, Laura Smith wrote: > >=20 > > > Could someone kindly help me out with the correct syntax ? > > >=20 > > > My first thought was the below but that doesn't work: > > >=20 > > > update foo set upper(bar_times)=3Dupper(bar_times)+interval '1' hour = where bar_id=3D'abc'; > > > ERROR: syntax error at or near "(" > > > LINE 1: update event_sessions set upper(bar_times)=3Dupper(bar_ti... > >=20 > > Use the constructor function: > >=20 > > UPDATE foo SET bar_times =3D tstzrange(lower(bar_times), upper(bar_time= s) + interval '1' hour); > >=20 > > 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. > >=20 > > https://www.postgresql.org/docs/current/rangetypes.html#RANGETYPES-CONS= TRUCT >=20 >=20 > If you need to preserve the information whether the upper and lower bound= s > are inclusive or not, you could >=20 > UPDATE foo > SET bar_times =3D 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 ... >=20 > Yours, > Laurenz Albe