Listing 1: Code That Determines the Number of Days for the NHNM Example WHEN @D = 'M' AND @C = 'N' THEN (SELECT +COUNT(*) FROM Calendar WHERE dte < DATEADD(mm, +1, @edate) AND dte >= @edate)