Dynamically populated schedule w/calculations

The above image is from an excel spreadsheet that I need to replicate into an HTML table. The data is pulled from a SQL Server 2005 database, and I'm using CFMX7.
Essentially, the table above shows that there are 2 employees, and 1 is available to be used elsewhere, if both employees are there. However, if one is out on vacation/off (for 2 or more days in a row), then that particular week is depleted by 1 (meaning they can't afford to send anyone out).
So, in the first series of columns, William Mays is on vacation for 2 or more days; therefore, for that week (4/5 - 4/11), they are depleted 1, so a 0 is shown below.
In the 2nd week, Mike Jackson is OFF 2 or more days and William is on vacation 2 or more days. This would deplete the week by 2, but there can't be a negative number showing, so it just shows 0. If, for example the Available was 3, then the number below would show 1, as 3 - 2 = 1.
In the last week, nobody is off, so the number below is 1.
This data is in SQL and is mapped out dynamically for the whole year, so I'll have to put the calculations in a loop. Also, how could I dynamically put a colspan (like it shows in the image above) in for 7 days at a time, from Sun thru Sat?
Thanks!
