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 1ooqgK-0007Ze-W0 for pgsql-general@arkaria.postgresql.org; Sat, 29 Oct 2022 18:35:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ooqgI-0001Pa-6C for pgsql-general@arkaria.postgresql.org; Sat, 29 Oct 2022 18:35:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ooqgH-0001PR-R9 for pgsql-general@lists.postgresql.org; Sat, 29 Oct 2022 18:35:41 +0000 Received: from mout-u-107.mailbox.org ([80.241.59.207]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ooqgB-0003JA-7I for pgsql-general@lists.postgresql.org; Sat, 29 Oct 2022 18:35:41 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4N07QC0Qv2z9tWf; Sat, 29 Oct 2022 20:35:31 +0200 (CEST) Date: Sat, 29 Oct 2022 20:35:30 +0200 (CEST) From: Erik Wienhold To: Eagna , "pgsql-general@lists.postgresql.org" Message-ID: <629544703.694927.1667068530445@office.mailbox.org> In-Reply-To: References: Subject: Re: How to add a variable to a timestamp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Rspamd-Queue-Id: 4N07QC0Qv2z9tWf List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 29/10/2022 19:35 CEST Eagna wrote: > > I'm trying to do something like this. > > SELECT > d.i, > h.i, > > '2022-10-31 00:00:00'::TIMESTAMP + INTERVAL 'd.i DAY' > FROM > GENERATE_SERIES(0, 6) AS d(i), > GENERATE_SERIES(0, 23) AS h(i); > > where I add d.i days (and also h.i hours) to a timestamp. > > I can't seem to get this to work. Any ideas appreciated. Create the interval with make_interval(days => d.i, hours => h.i). https://www.postgresql.org/docs/15/functions-datetime.html#id-1.5.8.15.6.2.2.28.1.1.1 -- Erik