I have two columns like that:
ihour (type=HH:mm:ss) 06:40:41
its (type=timestamp) 2020-12-10 00:00:00.000000
I want to add ihour to the its column and have a single column showing me date and time. How can I do this in Vertica? If you know how to do it in another db’s, I would be happy because at least I could learn the way that I should follow in Vertica.
Advertisement
Answer
Cast the time to INTERVAL, and add the two:
WITH indata(ihour,its) AS ( SELECT TIME '06:40:41', TIMESTAMP '2020-12-10 00:00:00.000000' ) SELECT its + ihour::INTERVAL(6) AS timesum FROM indata; timesum 2020-12-10 06:40:41