Re: Finding free time period on non-continous tstzrange field values

2022-12-02 Thread Amitabh Kant
On Thu, Dec 1, 2022 at 7:59 PM Tom Lane wrote: > Amitabh Kant writes: > > I tried the following query : > > > SELECT tstzmultirange(tstzrange('2022-11-25 00:00:00', '2022-11-30 > > 00:00:00', '[]')) - > > range_agg(time_range) AS availability > > FROM test_time_range > > WHERE time_range && ts

Re: Finding free time period on non-continous tstzrange field values

2022-12-01 Thread Tom Lane
Amitabh Kant writes: > I tried the following query : > SELECT tstzmultirange(tstzrange('2022-11-25 00:00:00', '2022-11-30 > 00:00:00', '[]')) - > range_agg(time_range) AS availability > FROM test_time_range > WHERE time_range && tstzrange('2022-11-25 00:00:00', '2022-11-30 00:00:00', > '[]');

Re: Finding free time period on non-continous tstzrange field values

2022-11-30 Thread Amitabh Kant
On Wed, Nov 30, 2022 at 7:13 PM Amitabh Kant wrote: > Hi > > Given the following table, how do I find free time period. > > CREATE TABLE test_time_range ( > id SERIAL PRIMARY KEY, > time_range tstzrange); > > > Insert into test_time_range(time_range) values('[2022-11-28 08:00:00, > 2022-1

Re: Finding free time period on non-continous tstzrange field values

2022-11-30 Thread Amitabh Kant
On Wed, Nov 30, 2022 at 7:20 PM Marcos Pegoraro wrote: > Given the following table, how do I find free time period. >> > > > https://www.crunchydata.com/blog/better-range-types-in-postgres-14-turning-100-lines-of-sql-into-3 > Thanks Marcos .. Had seen this earlier but somehow slipped my mind to

Re: Finding free time period on non-continous tstzrange field values

2022-11-30 Thread Marcos Pegoraro
> > Given the following table, how do I find free time period. > https://www.crunchydata.com/blog/better-range-types-in-postgres-14-turning-100-lines-of-sql-into-3

Finding free time period on non-continous tstzrange field values

2022-11-30 Thread Amitabh Kant
Hi Given the following table, how do I find free time period. CREATE TABLE test_time_range ( id SERIAL PRIMARY KEY, time_range tstzrange); Insert into test_time_range(time_range) values('[2022-11-28 08:00:00, 2022-11-28 20:00:00]'); Insert into test_time_range(time_range) values('[2022-