title: SQL Server Adjusting calculation when Bool is changed
body: <p>In Sql Server I am trying to add a column to calculate employees Extra Leave based on their start date, where apprentices do not get any. But I am getting an error. <code>Incorrect syntax near the keyword 'AS'</code>. </p>
  
  <p>Also would there be a way that the extra leave starts calculating after their <code>Apprentice</code> is set to False. </p>
  
  <pre><code>ALTER TABLE [dbo].[Employee]
  ADD AwardedLeave as CAST 
  (
  
  
  CASE
  When [Apprentice] = 'True'Then 0
  When [Apprentice] = 'False' Then 
  CASE 
  
  WHEN GETDATE() BETWEEN DATEFROMPARTS(YEAR([StartDate]),01,01) AND 
  DATEFROMPARTS(YEAR([StartDate])+1,12,31)  THEN 0
  WHEN GETDATE() BETWEEN DATEFROMPARTS(YEAR([StartDate])+2,01,01) AND 
  DATEFROMPARTS(YEAR([StartDate])+2,12,31) THEN 8
  WHEN GETDATE() BETWEEN DATEFROMPARTS(YEAR([StartDate])+3,01,01) AND 
  DATEFROMPARTS(YEAR([StartDate])+3,12,31) THEN 16
  WHEN GETDATE() BETWEEN DATEFROMPARTS(YEAR([StartDate])+4,01,01) AND 
  DATEFROMPARTS(YEAR([StartDate])+4,12,31) THEN 24 
  WHEN GETDATE() BETWEEN DATEFROMPARTS(YEAR([StartDate])+5,01,01) AND 
  DATEFROMPARTS(YEAR([StartDate])+5,12,31) THEN 32
  WHEN GETDATE() BETWEEN DATEFROMPARTS(YEAR([StartDate])+6,01,01) AND 
  DATEFROMPARTS(YEAR([StartDate])+1000,12,31) THEN 40 
  
  END 
  
  +
  
  CASE 
  WHEN DATEFROMPARTS(YEAR(StartDate), 12,31) &gt;= GETDATE() THEN datediff(day, 
  [StartDate],datefromparts(datepart(year,[StartDate]),(12), 
  (31)))/(30.42)*13.33
  ELSE [ALCategory]
  END AS int 
  
  )  
  </code></pre>