Print Page | Close Window

Identifying week number

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9655
Printed Date: 31 March 2026 at 9:41pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Identifying week number
Posted By: stevem2003
Subject: Identifying week number
Date Posted: 09 February 2004 at 7:44am

Hi, I have the following code:
<%
dim conn, rs, strconn, strSQL

strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("database")
set conn = server.createobject("adodb.connection")
conn.open strconn
strSQL = "SELECT * FROM table ORDER BY id ASC;"
set rs = server.createobject("adodb.recordset")
rs.open strSQL, conn, 3, 3
%>
<table border="1" width="763">
<tr>
<th>ID</th>
<th>Week Number</th>
<th>On Call Person 1</th>
<th>On Call Person 2</th>
<th>Duty Person</th>
<th>Week Start</th>
</tr>
<% Do While Not rs.EOF %>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("weekno")%></td>
<td><%=rs("callout1")%></td>
<td><%=rs("callout2")%></td>
<td><%=rs("duty")%></td>
<td><%=rs("weekstart")%></td>
</tr>
<%
rs.MoveNext
Loop
%>
</table>

What I want to do is highlight this weeks data, so for instance the field weekno contains 7 and start date as 09/02/04.

Therefore how can I identify the record which will be applicable during this week?

Any help would be appreciated.

TIA
Steve



-------------
There's no point running if you're on the wrong road!



Replies:
Posted By: MorningZ
Date Posted: 09 February 2004 at 6:06pm

Keep in mind i have absolutely zero idea of the rest of the app except what you show, but here's a shot at it.. this is what i would do:
- Take the take from the database
- Figure out the dates of Sun and Sat of whatever date is from DB
- If today's date is in between these, then highlight it

So here's this kinda coded up, but again, i can't guarentee it works as is since i have nothing else to go on

<% Do While Not rs.EOF %>
<%
'Make sure its a Date object
StartDate = Cdate(rs("weekstart"))
'Get the "Day of Week"
StartDayOfWeek = WeekDay(StartDate)
'Basically gets the date of "Day number 1" (sun) for this week
ThisWeek_Sunday = DateAdd(d,-(StartDayOfWeek - 1),StartDate)
'Basically gets the date of "Day number 7" (sat) for this week
ThisWeek_Saturday = DateAdd(d,(7 - StartDayOfWeek),StartDate)

if Date() >= ThisWeek_Sunday and Date() <= ThisWeek_Saturday then
    'So today is in this range, so highlight it
    Response.Write("<tr bgcolor=""#c0c0c0c0"">") 
else
    'Else don't
    Response.Write("<tr>")
end if

%>
<td><%=rs("id")%></td>
<td><%=rs("weekno")%></td>
<td><%=rs("callout1")%></td>
<td><%=rs("callout2")%></td>
<td><%=rs("duty")%></td>
<td><%=rs("weekstart")%></td>
</tr>
<%
rs.MoveNext
Loop
%>



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: stevem2003
Date Posted: 10 February 2004 at 5:10am

Many Thanks MorningZ

I have been able to modify it, so that it works



-------------
There's no point running if you're on the wrong road!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net