In amazon redshift I would like to add number of hours to a time field
tt_time hours_add
12:00:00 1
15:30:00 3
16:00:00 6
Expected Output
13:00:00
18:00:00
22:00:00
In amazon redshift I would like to add number of hours to a time field
tt_time hours_add
12:00:00 1
15:30:00 3
16:00:00 6
Expected Output
13:00:00
18:00:00
22:00:00
You can use the DATEADD Redshift function, using "h", "hr" or "hrs" as your first parameter. Documentation for this function can be found here and here.
This sql statement should work for you, assuming you want to create a new table to hold your results:
INSERT into new_table_name SELECT DATEADD(hr,hours_add,tt_time) FROM current_table_name;