What is the syntax for specifying a date to a variable without the year? For example, I have a parameter of @YEAR and I want the @STARTDATE variable to always be '1/1/@YEAR'.
Declare @Year Int
Set @Year = 2009
Declare @StartDate DateTime
Set @StartDate = DateAdd(Year, @Year-1900, '1900-01-01')
Select @StartDate
If you subtract 1900 from your year and then add that number of years to January 1, 1900, you will end up with a date that is January 1 of whatever year you want.
-George
Microsoft SQL Server MVP My Blogs SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.