Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2001
    Posts
    12

    Unanswered: need advice about how to display result from database

    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>&nbsp;&nbsp;</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>&nbsp;&nbsp;</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,

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Try the following inserting html where needed (this has not been tested):

    strDesc = ""
    initial = ""
    While Not rs.EOF
    ScheduleDate = rs.fields("ScheduleDate").Value
    If initial <> rs.fields("Initial").Value Then
    initial = Trim(rs.fields("Initial").Value) 'AA, BB
    If strDesc <> "" Then
    If strEndDate <> "" Then
    strDate = strBeginDate & "-" & strEndDate
    Else
    strDate = strBeginDate
    End If
    strDesc = strDesc & "," & strDate
    strDesc = ""
    End If
    initial = rs.fields("Initial").Value
    strDesc = initial
    strBeginDate = Day(ScheduleDate)
    ScheduleDateOld = ScheduleDate
    strEndDate = ""
    Else
    If (Day(ScheduleDateOld) + 1) <> Day(ScheduleDate) Then
    If strEndDate <> "" Then
    strDate = strBeginDate & "-" & strEndDate
    Else
    strDate = strBeginDate
    End If
    strDesc = strDesc & "," & strDate
    strEndDate = ""
    strBeginDate = Day(ScheduleDate)
    Else
    strEndDate = Day(ScheduleDate)
    End If
    ScheduleDateOld = ScheduleDate
    End If
    rs.movenext
    If rs.EOF Then
    If strEndDate <> "" Then
    strDate = strBeginDate & "-" & strEndDate
    Else
    strDate = strBeginDate
    End If
    strDesc = strDesc & "," & strDate
    End If
    Wend

  3. #3
    Join Date
    Oct 2001
    Posts
    12
    Thank you anyway. I'll try.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •