Search Postgresql Archives

Re: How to add a variable to a timestamp.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <https://proton.me/> secure email.



--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux