Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrewO-001u3C-HI for pgsql-general@arkaria.postgresql.org; Tue, 02 Apr 2024 14:16:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rrewN-0090eK-GU for pgsql-general@arkaria.postgresql.org; Tue, 02 Apr 2024 14:16:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrewN-0090eC-6M for pgsql-general@lists.postgresql.org; Tue, 02 Apr 2024 14:16:43 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rrewK-000EvD-Eq for pgsql-general@lists.postgresql.org; Tue, 02 Apr 2024 14:16:42 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2d48f03a8bbso53710751fa.0 for ; Tue, 02 Apr 2024 07:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712067400; x=1712672200; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cAZMih7X9dhuyi78ZhD5KcutGgaoeaxK7jGyiuz4ocY=; b=ZLyhv4XojWcI+CwJgsyZyt7MYwPEYT0GEP2w0lhZeuj/8Xtx30LaHutwbrnj0vLsqW fPhb8Y1Xb6J/HfHj9ZelHLATn9yLDulcx8SzYbIDgC1hIB6cErL4A0XRsQ7BEFa6GRVj e8DdIhhJoHoOrgdXIKu6lqHUpoVnDo5pfCbjj91le+N4FBgve+Of5XNPIbU2+95eyMsm 66sDAevAylkjCg7eOYiTkyF3u7KDSWOEYA9FvvgNpS8K6eDE9oYM2dGfrLpt60wfg2WK yEJOIHJbs/eXfFoDXQLkKwl98nehw4xDJqAveq6N6GARISI7MKi/H3oyIy65Ca78cykS pmXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712067400; x=1712672200; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cAZMih7X9dhuyi78ZhD5KcutGgaoeaxK7jGyiuz4ocY=; b=dCpW0D6rm2GuC56ilsqZb8u2PiKXAVUj5qLc780CX6xD6D3RmKDxofaffS4WaqEaVO D3Njf23h8thnUhtSQHHl1XWmI8W2ZT9Rw6ZCXlR7uY48QVoUwDA75/6Dghfc6aymfzir Cdaa8Rd2ZdJyi3lEoADqjh473oiuSSxGbha9B+caS8l+YF3mSOGTmw+1k4asgz4VgUJz DCqRnWCSwgZJzYFI2QFUmsjLMR+vKUEEp94snZnssPVFXp1ycsyXc9RicfaM1yQhmzo1 kflD78fSkVQRjnRhj0Jiqs3MaaMKPU2IhGS0KBURsIHq8EJuoDJ00tQJonT97psdYpZj j9Hg== X-Forwarded-Encrypted: i=1; AJvYcCV+w6wbh8xj0Q1Ma59TSBwuwwGKFeCBJQnd+TZNqVpau3H7PxPrHcdKd0mf5IPnqfg+t/KFkQaw8X8Ma25+dIAiRGgbuQhWiPx0kH2OZbUv1UQU X-Gm-Message-State: AOJu0YwDqSBfsBqVrvrmNoFr81giZfPSLFPXad5R1o4vcqoiOcAiygpD 0PNddY4FkHxdCCPyqBgM3oE29H0zwo5GGtq9CrNm5XEA4z/UaWOnr8dA+wXTl93oTGBbOMN4tY7 ICjWmw7uVPFZNtXi49vwP0JbNAyQ= X-Google-Smtp-Source: AGHT+IFMgL77QBxHkPtyWNo6vXQ+uNg2DRGOJIZZc5o6VcYt/UzyhrTSYQTQrVP1QIVkkNPdrUxC5aCNeEftWp89Z38= X-Received: by 2002:a2e:b0f9:0:b0:2d8:e0b:4757 with SMTP id h25-20020a2eb0f9000000b002d80e0b4757mr2320862ljl.10.1712067399386; Tue, 02 Apr 2024 07:16:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Tue, 2 Apr 2024 10:16:04 -0400 Message-ID: Subject: Re: Timestamp conversion Error in dynamic sql script To: Erik Wienhold Cc: sud , pgsql-general Content-Type: multipart/alternative; boundary="0000000000002c130906151dc1be" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002c130906151dc1be Content-Type: text/plain; charset="UTF-8" > > 1. Declare start_date as DATE when you want to add days with date + int > 2. Keep TIMESTAMP and use start_date + make_interval(days => i) > Also 0. Use TIMESTAMPTZ not TIMESTAMP Cheers, Greg --0000000000002c130906151dc1be Content-Type: text/html; charset="UTF-8"
1. Declare start_date as DATE when you want to add days with date + int
2. Keep TIMESTAMP and use start_date + make_interval(days => i)

Also

0. Use TIMESTAMPTZ not TIMESTAMP

Cheers,
Greg

--0000000000002c130906151dc1be--