I need to add number of days to a column. Below is the code I need to modify:
DATE_TRUNC('day', a.targetdeliverydateforcalc) + COALESCE(a.to_transit_time_amount, 0) + 2
I tried this (and similar variations):
DATE_TRUNC('day', a.targetdeliverydateforcalc) + INTERVAL ||COALESCE(a.to_transit_time_amount, 0) + 2 || 'day')
Two ways come to mind to solve this. Computing the days then converting to an interval:
or calculate the number of days and just add the resulting integer: