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 1oosA8-00035n-JZ for pgsql-general@arkaria.postgresql.org; Sat, 29 Oct 2022 20:10:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oosA7-0002OS-74 for pgsql-general@arkaria.postgresql.org; Sat, 29 Oct 2022 20:10:35 +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 1oosA6-0002OJ-7X for pgsql-general@lists.postgresql.org; Sat, 29 Oct 2022 20:10:34 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oosA2-00044y-8Y for pgsql-general@lists.postgresql.org; Sat, 29 Oct 2022 20:10:33 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 4E7353200564; Sat, 29 Oct 2022 16:10:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 29 Oct 2022 16:10:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1667074225; x= 1667160625; bh=df5CdF6ICIAh5ttdkH1mMl+drwN2kV0M8WbIQ669gZI=; b=S 0CosNYLqDe1DF4lC/2jaK2R84Ul3D4MbfX+ufrgD9cMFE4KwUOE2MjAtzjfv19fi jjAem4rZ8096Ahv+ieWQdnQhc8ki72o9ZiFL3+53PETq2uiEF0hm54lQE3GvJp3k 30RdcuIwncEVWfpD4Y7CGQtVFKOScNXvwuV2NVg47WAVtpQORkqB9kQMO4ssl42o bSQ9lvh8Z0TqJuepDa6ZdFyRLObt1UYuTs9YKzXOr6Z8WSEaFyuJLxY5SnU8SyLm I6gFexHuFoCrLuoeKMUIrYA4p/cTdllI9f4XhfPUhh8mxi/KolS551cFHbpJ2RTP 0J2vPgQJnGD+qu99OrwmQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1667074225; x=1667160625; bh=d f5CdF6ICIAh5ttdkH1mMl+drwN2kV0M8WbIQ669gZI=; b=rLZ4HQe+H5yGf5TMW SEC6W7c1F79Ylh3Gin8IUhaXNQe758vfgML4nD96HQ50ITK5Zop6XKZHBPF7kmkW fJ2h+5jQoPwdVLLoaudetQlNsQ46hvt5xVxvmF++xE/r9NCOIa2DNGFmDFJ40+ee JhGA/t589PWaHsNIBubpOPbsf4WJssnEMep/RRvZxtw8N8RFv4jearjbqZrIuoMA 9FqhtY5OjOFpQbB0KIaRtnLgIRxB/0huhrrOS8an+dxLLk5XwuBw92afJL0iCjDD SU2bZIHPfBoJJUbef3CCOZv8hct3jC+zN55sQ2xG7RVanNBm7M0C3K7sx/DA0R8Q SH+Qg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrtdekgddugeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnheptddufeegte etgfeuiefhleekffehudduveekueevtdelhfeigfdvffelueffgfetnecuffhomhgrihhn pehprhhothhonhdrmhgvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 29 Oct 2022 16:10:24 -0400 (EDT) Message-ID: <3a501613-e76e-7c70-2476-e2ea4df40243@aklaver.com> Date: Sat, 29 Oct 2022 13:10:24 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: How to add a variable to a timestamp. To: Eagna , "pgsql-general@lists.postgresql.org" References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/29/22 10:35, Eagna wrote: > > Hi, > > 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. SELECT d.i, h.i, '2022-10-31 00:00:00'::TIMESTAMP + (d.i::text || ' DAY ' || h.i::text || ' HOUR')::interval FROM GENERATE_SERIES(0, 6) AS d(i), GENERATE_SERIES(0, 23) AS h(i); > > > E. > > Sent with Proton Mail secure email. > > -- Adrian Klaver adrian.klaver@aklaver.com