combining date with string as a parameter in sql filter

Hello,

I am trying to put a filter in sql 2008 view for the date field. I have the current year year(getdate()) and I need to use a string '8/31/' as a permanent month and day so the parameter will be '8/31/2013' and the next year '8/31/2014'. I am trying to do this
 '8/31/'+year(getdate()) but getting an error "Conversion failed when converting the varchar value '8/31/' to datatype int." How  I can write it correctly?
Galina BesselyanovaSenior Software Developer/EngineerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
deast05Connect With a Mentor Commented:
The year(getdate()) portion is treated like a number and SQL is attempting to perform addition.  You'll want to convert it to a string by doing something similar to:

select '8/31/' + convert(varchar(4), year(getdate()))
from table1
0
 
Galina BesselyanovaSenior Software Developer/EngineerAuthor Commented:
Great, Thank you very much.
0
 
PaulCommented:
or you can use "datename" which returns a character string

select '8/31/' + datename(year,getdate() )
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.