Amour22015
asked on
TSQL - Convert string to ?
Hi Experts,
I have this part of a select:
When I execute I get a syntax error:
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value '7/1/' to data type int.
If I do this:
It clears out the syntax but gives me a -1 in the YearAgo which I am not looking for. I am looking for:
7/1/What ever the year is for [intProgYear].
Please help and thanks...
I have this part of a select:
('7/1/'+[intProgYear]-1) As YearAgo
When I execute I get a syntax error:
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value '7/1/' to data type int.
If I do this:
(7/1/+[intProgYear]-1) As YearAgo
It clears out the syntax but gives me a -1 in the YearAgo which I am not looking for. I am looking for:
7/1/What ever the year is for [intProgYear].
Please help and thanks...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just what I am looking for thank you, Great
If a string then Vikas's solution should work for you.