From: | Erik Wienhold <ewie(at)ewie(dot)name> |
---|---|
To: | Laura Smith <n5d9xq3ti233xiyif2vp(at)protonmail(dot)ch> |
Cc: | postgre <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: How to update upper-bound of tstzrange ? |
Date: | 2024-05-20 11:56:21 |
Message-ID: | d45bbb8e-f42d-4bce-b3b0-46bce8f18ef4@ewie.name |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
--
Erik
From | Date | Subject | |
---|---|---|---|
Next Message | Rich Shepard | 2024-05-20 12:33:37 | Re: Updating 457 rows in a table |
Previous Message | milist ujang | 2024-05-20 11:18:30 | Re: signal 11: Segmentation fault ; query constraint list; pg16.3 |