------use variables
DECLARE @THISDAY AS DATETIME =  getdate() -- By default this selects today for the "as of" date
DECLARE @StarDate AS DATETIME = '2/1/2017' -- The date to start counting days enrolled and absent.
DECLARE @EndDate AS DATETIME = '6/1/2017' -- (select max(dt) from day where del = 0 and ho in (''))

--Don't change this
DECLARE @EnrYear AS nvarchar(4) = '20'  + substring(db_name(),4,2)

SELECT STU.SC, STU.SN, STU.ID, STU.LN, STU.FN, STU.MN, STU.bd, STU.CID, ENR.GR, ENR.ED, ENR.LD,
  (SELECT COUNT(DAY.DT) FROM DAY WHERE DAY.DEL = 0 and DAY.DT <= @THISDAY AND DAY.SC = STU.SC AND 
  DAY.HO = '' AND DAY.DT >= ENR.ED AND DAY.DT <=  @EndDate and day.dt >= @StarDate) as DaysENR,
  (SELECT COUNT(ATT.DT) FROM ATT INNER JOIN ABS ON ATT.SC = ABS.SC AND ATT.AL = ABS.CD 
  WHERE ATT.DT <= @THISDAY AND ATT.DEL = 0 AND ABS.AD = 0 AND ATT.DT >= ENR.ED AND ATT.DT 
  <= @EndDate AND ATT.DT >= @StarDate AND ATT.SC = STU.SC AND ATT.SN = STU.SN) AS DaysAbs,
    (SELECT COUNT(ATT.DT) FROM ATT INNER JOIN ABS ON ATT.SC = ABS.SC AND ATT.AL = ABS.CD 
  WHERE ABS.TY = 3 and ATT.DT <= @THISDAY AND ATT.DEL = 0 AND ABS.AD = 0 AND ATT.DT >= ENR.ED AND ATT.DT 
  <= @EndDate AND ATT.DT >= @StarDate AND ATT.SC = STU.SC AND ATT.SN = STU.SN) AS DaysUnexcused

FROM STU INNER JOIN ENR ON STU.SC = ENR.SC AND STU.SN = ENR.SN
WHERE ENR.YR = @EnrYear AND STU.DEL= 0 AND ENR.DEL = 0 and enr.ed <= @EndDate and isnull(enr.ld,@EndDate) >= @StarDate