Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0kZO-0005LN-Kc for pgsql-general@arkaria.postgresql.org; Thu, 01 Dec 2022 14:29:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p0kZN-0005Ao-En for pgsql-general@arkaria.postgresql.org; Thu, 01 Dec 2022 14:29:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0kZN-0005Ae-3q for pgsql-general@lists.postgresql.org; Thu, 01 Dec 2022 14:29:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0kZK-00045t-Sd for pgsql-general@postgresql.org; Thu, 01 Dec 2022 14:29:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2B1ETdbh1564926; Thu, 1 Dec 2022 09:29:39 -0500 From: Tom Lane To: Amitabh Kant cc: PGSQL Mailing List , Marcos Pegoraro Subject: Re: Finding free time period on non-continous tstzrange field values In-reply-to: References: Comments: In-reply-to Amitabh Kant message dated "Thu, 01 Dec 2022 13:14:20 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1564924.1669904979.1@sss.pgh.pa.us> Date: Thu, 01 Dec 2022 09:29:39 -0500 Message-ID: <1564925.1669904979@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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', > '[]'); > but then I receive the following error. My guess is I need to cast the > tstzrange output, but can't seem to find the correct cast. > ERROR: function tstzmultirange(tstzrange) does not exist > LINE 1: SELECT tstzmultirange(tstzrange('2022-11-25 00:00:00', '2022... ^ > HINT: No function matches the given name and argument types. You might need > to add explicit type casts. SQL state: 42883 Character: 8 That function certainly should exist: psql (14.6) Type "help" for help. postgres=# \df tstzmultirange List of functions Schema | Name | Result data type | Argument data types | Type ------------+----------------+------------------+----------------------+------ pg_catalog | tstzmultirange | tstzmultirange | | func pg_catalog | tstzmultirange | tstzmultirange | VARIADIC tstzrange[] | func pg_catalog | tstzmultirange | tstzmultirange | tstzrange | func (3 rows) My guess is that your server is not in fact PG14, but some older version. regards, tom lane