Hi,
I have a collumn that contains the first parameter for the dateadd function. (i.e. WEEK, MONTH, etc)
I want to use this value in the where statement of a query but get the following error:
' + cast(T.AddString as varchar ) + ' is not a recognized dateadd option.
Or
Invalid parameter 1 specified for dateadd.
These are some of the code options I tried:
dateadd(cast(T.AddString as varchar) , cast(t.AddNumber as int) , GETDATE())
dateadd(' + cast(T.AddString as varchar) +' , cast(t.AddNumber as int) , GETDATE())
dateadd("'" + cast(T.AddString as varchar) +"'" , cast(t.AddNumber as int) , GETDATE())
Is it possible to use a collumn value in a dateadd function?
Thanks
I have a collumn that contains the first parameter for the dateadd function. (i.e. WEEK, MONTH, etc)
I want to use this value in the where statement of a query but get the following error:
' + cast(T.AddString as varchar ) + ' is not a recognized dateadd option.
Or
Invalid parameter 1 specified for dateadd.
These are some of the code options I tried:
dateadd(cast(T.AddString as varchar) , cast(t.AddNumber as int) , GETDATE())
dateadd(' + cast(T.AddString as varchar) +' , cast(t.AddNumber as int) , GETDATE())
dateadd("'" + cast(T.AddString as varchar) +"'" , cast(t.AddNumber as int) , GETDATE())
Is it possible to use a collumn value in a dateadd function?
Thanks