Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Identifying week number
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Identifying week number

 Post Reply Post Reply
Author
stevem2003 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevem2003 Quote  Post ReplyReply Direct Link To This Post Topic: Identifying week number
    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

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
%>



Edited by MorningZ
Contribute to the working anarchy we fondly call the Internet
Back to Top
stevem2003 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevem2003 Quote  Post ReplyReply Direct Link To This Post Posted: 10 February 2004 at 5:10am

Many Thanks MorningZ

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

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.