Unanswered: Can we use a variable as an argument in a user defined function
I have written a user defined function to convert a date from an OLD time zone to NEW time Zone. The three parameters are (date, OLDTz,NEWTZ).
@v_tz varchar(10) ,
select getdate(), dateadd(day, 7, getdate()), dateadd(day, @v_da, getdate())
select top 2 timestampwhenset, dbo.tc(timestampwhenset,'GMT','PST') from s_monitorevents
select top 2 timestampwhenset, dbo.tc(timestampwhenset,'GMT', @v_tz ) from s_monitorevents
In real life the value of @v_tz is coming from a table. How do I go about resolving the value of the variable before I run the function. I was able to use the variable substitution successfully in a numeric function as well as in a string/character function.