I have a set of date from database following this:
Type ScheduleDate
---- ------------
AA 1/3/2003
AA 1/5/2003
AA 1/13/2003
AA 1/14/2003
AA 1/17/2003
...so and so
BB 1/1/2003
BB 1/2/2003
BB 1/3/2003
BB 1/18/2003
BB 1/19/2003
BB 1/25/2003
But I like to show those dates like this intead:
AA 3, 5, 13-14, 17-19, 24-26, 28
BB 1-3, 18-19, 25
Here is my code:
while not rs.eof
Initial = rs.fields("Initial").value 'AA, BB
ScheduleDate = rs.fields("ScheduleDate").value
if oInitial <> rs.fields("Initial").value then
%>
<tr>
<td class=LightGray3D id=10 colspan=5><%= Initial %></td>
</tr>
<%
Count = 1
' assign firstDay to compare next day
firstDay = ScheduleDate
lastDay = firstDay
nextDay = DateAdd("d", Count, firstDay)
%>
<tr>
<td id=8><%= Day(ScheduleDate) %></td>
<td id=8><font color=Navy><% if oFirstDay <> firstDay then %>firstDay=<%= Day(firstDay) %><% end if %></font></td>
<td id=8><font color=Gray>Count=<%= Count %></font> </td>
<td id=8><font color=Blue>nextDay=<%= Day(nextDay) %></font></td>
<td id=8><font color=Blue>
lastDay=<%= Day(lastDay) %>
</font></td>
<%
else
' assign firstDay to compare next day
lastDay = ScheduleDate
if DateAdd("d", Count, firstDay) = ScheduleDate then
Count = Count + 1
nextDay = DateAdd("d", Count, firstDay)
else
firstDay = ScheduleDate
lastDay = firstDay
nextDay = DateAdd("d", 1, firstDay)
Count = 1
end if
%>
<tr>
<td id=8><%= Day(ScheduleDate) %></td>
<td id=8><font color=Navy><% if oFirstDay <> firstDay then %>firstDay=<%= Day(firstDay) %><% end if %></font></td>
<td id=8><font color=Gray>Count=<%= Count %></font> </td>
<td id=8><font color=Orange>nextDay=<%= Day(nextDay) %></font></td>
<td id=8><font color=Orange>
lastDay=<%= Day(lastDay) %>
</font></td>
<%
end if ' if oInitial <> rs.fields("Initial").value then
%>
</tr>
<%
oInitial = Initial
oFirstDay = firstDay
ScheduleDate = ""
lastDay = ""
Initial = ""
rs.movenext
wend
I know my code looks pretty bad but so far I can get first day of each date set but I don't know how to show only last day of each date set. Like Type=BB, Date=1/1/2003, 1/2/2003, 1/3/2003 -- I only want to show text "BB 1-3".
I've been doing this for 2 days now. So please, if anybody don't mind to give me an advice, I'll appreciate it.
Thank you in advance,