Reputation: 41
I want to add a dynamic number of days to Date but the existing Date_Add function in BigQuery is not allowing me to replace interval integer with a column name. Is there another function or workaround to achieve this?
Example of what I'd want to achieve using the Date_Add function. This is throwing me an error.
Date_Add(due_date, interval dynamic_col_nme day)
If due_date = 6/10/2019 and dynamic_col_nme = 5 then the expected result is 6/15/2019.
Upvotes: 0
Views: 3109
Reputation: 1270503
You use date_add()
:
select date_add(due_date, interval dynamic_col_nme day)
This works fine when I try it in Standard SQL:
select date_add(dte, interval n day)
from (select current_date as dte, 5 as n union all
SELECT CURRENT_DATE, 10
) x
Upvotes: 2