I have tried:
add_months('date_column', -'number_of_months_column')
I get:
error [3535] A character string failed conversion to a numeric value.
Is what I am trying to do possible with the add_months
option?
Why do you use single quotes around column names?
If number_of_months_column
's data type is integer
then this should work:
add_months(date_column, -number_of_months_column)
If number_of_months_column
is a string then you must convert it first to an integer:
add_months(date_column, -to_number(number_of_months_column))
or:
add_months(date_column, -cast(to_number(number_of_months_column) as integer))
or:
add_months(date_column, -trycast(to_number(number_of_months_column) as integer))