title: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value exception
body: <p>I was trying to concatenate the date and month with the Year and I need to check with the each record to find the financial year. When I execute the query it shows (<strong>The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.</strong>) error. Please help me to find the issue.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>   set @SiteFileVal1='04-01'
     set @SiteFileVal2='03-31'
     set @SiteFileYear='2013'
  
     SELECT bb.Amount
     FROM Budget bb
     JOIN Invoice i ON i.AccountId=bb.AccountId
     WHERE bb.AccountId=i.AccountId
     AND bb.Year=
     (SELECT CASE WHEN (i.Date &gt;= convert(datetime,@SiteFileVal1+'-'+convert(varchar(200),DATEPART(yyyy,i.Date)))
                     AND i.Date &lt; convert(datetime,@SiteFileVal2+'-'+convert(varchar(200), DATEADD(yyyy,1,DATEPART(yyyy,i.Date))))) THEN year(@SiteFileYear) ELSE DATEADD(yyyy,-1,DATEPART(yyyy,i.Date)) END)
  </code></pre>