Link to home
Start Free TrialLog in
Avatar of Amour22015
Amour22015

asked on

TSQL - Convert string to ?

Hi Experts,

I have this part of a select:
('7/1/'+[intProgYear]-1) As YearAgo

Open in new window


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

Open in new window


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
Avatar of Vikas Garg
Vikas Garg
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Which data type do you want to be returned?
If a string then Vikas's solution should work for you.
Avatar of Amour22015
Amour22015

ASKER

Just what I am looking for thank you, Great