[prev in list] [next in list] [prev in thread] [next in thread]
List: postgresql-general
Subject: How to add a variable to a timestamp.
From: Eagna <eagna () protonmail ! com>
Date: 2022-10-29 17:35:22
Message-ID: xXb-4R7uS7KbJF86CCk3x54iPj_ZoDNpAE33QlL7UUD27u0POej_mrycXGj9wYvc_N9XSP5Ed2cw5YF9YLGynDEWAq0aMY_7NkzO4BykQnw= () protonmail ! com
[Download RAW message or body]
[Attachment #2 (text/plain)]
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.
E.
Sent with [Proton Mail](https://proton.me/) secure email.
[Attachment #3 (text/html)]
<div style="font-family: Arial; font-size: 14px;"><br></div><div style="font-family: \
Arial; font-size: 14px;">Hi,</div><div style="font-family: Arial; font-size: \
14px;"><br></div><div style="font-family: Arial; font-size: 14px;">I'm trying to do \
something like this.</div><div style="font-family: Arial; font-size: \
14px;"><br></div><div style="font-family: Arial; font-size: \
14px;"><span>SELECT</span><div><span> d.i,</span></div><div><span> \
h.i,</span></div><div><br></div><div><span> '2022-10-31 00:00:00'::TIMESTAMP \
+ INTERVAL 'd.i DAY'</span></div><div><span>FROM </span></div><div><span> \
GENERATE_SERIES(0, 6) AS d(i),</span></div><div><span> GENERATE_SERIES(0, \
23) AS h(i);</span></div><span></span></div><div style="font-family: Arial; \
font-size: 14px;"><br></div><div style="font-family: Arial; font-size: 14px;">where I \
add d.i days (and also h.i hours) to a timestamp.</div><div style="font-family: \
Arial; font-size: 14px;"><br></div><div style="font-family: Arial; font-size: \
14px;">I can't seem to get this to work. Any ideas appreciated.</div><div \
style="font-family: Arial; font-size: 14px;"><br></div><div style="font-family: \
Arial; font-size: 14px;"><br></div><div style="font-family: Arial; font-size: \
14px;">E.<br></div><div style="font-family: Arial; font-size: 14px;"><br></div> <div \
class="protonmail_signature_block" style="font-family: Arial; font-size: 14px;"> \
<div class="protonmail_signature_block-user protonmail_signature_block-empty">
</div>
<div class="protonmail_signature_block-proton">
Sent with <a target="_blank" href="https://proton.me/" rel="noopener \
noreferrer">Proton Mail</a> secure email. <br></div><div \
class="protonmail_signature_block-proton"><br></div><div \
class="protonmail_signature_block-proton"><br></div> </div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic