Den url du henviser til virker ikke!
Hvis jeg udskriver DatePart("ww",date(),2,2)får jeg ganske rigtig uge 53, men det dur ikke til mit script. Kort fortalt, så skal det allerede om søndagen vise næste uge, altså uge 1, og med de rigtige datoer. Jeg kan godt få vist de rigtige datoer, hvis jeg ændrer, så mandag ikke er den første dag i ugen, men så passer det ikke sammen med ugenummeret. Jeg smider lige hele scriptet op, så du kan se de forskellige datofunktioner. Jeg har ikke selv lavet funktionerne, så jeg har lidt svært ved at gennemskue dem. Det er helt klart et uge 53 problem, da det virkede fint i 2004 og også ved overgangen 2003/2004.
<%Session.LCID = &H0407%>
<%
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.Buffer = "true"
'hvis session("userID") er tom så er man ikke logget ind.
if session("userID") = "" then
Response.Redirect"../hovedlogin/loginform.asp"
Else
end if
%>
<%
uge = request.form("uge")
aar = request.form("aar")
xweek=DatePart("ww",date())
naar = aar + 1
if Request("mode") = "change" AND cint(uge)<xweek then
Response.redirect "skema.asp?reservation=" & request("reser") & "&uge=" & Request("uge") & "&aar=" & naar & ""
elseif Request("mode") = "change" AND cint(uge)>xweek then
Response.redirect "skema.asp?reservation=" & request("reser") & "&uge=" & Request("uge") & "&aar=" & aar & ""
end if
%>
<html>
<head>
<title>skema</title>
<LINK REL="StyleSheet"
HREF="../style.css"
TYPE="text/css">
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Tom Khoury (twaks@yahoo.com) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!!
http://javascript.internet.com -->
<!-- Begin
function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
}
}
}
}
// End -->
</script>
</head>
<body OnLoad="placeFocus()">
<p align="center"><br>
<table border=" solid 1px" width="100%" cellspacing="0" cellpadding="0" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#FFFFFF" >
<tr>
<td width="128%" colspan="6" bgcolor="#999999">
<table border="0" width="100%">
<tr>
<td width="25%" valign="bottom" bgcolor="#999999"><b><font face="Verdana" color="red" size="4">
<%response.write Request.Querystring("reservation")%>
</font></b></td>
<%
Function UgeTilDato(aar,uge,dag)
januar1 = DateSerial(aar, 1, 1)
ugedagjan1 = Weekday(januar1, vbMonday)
if ugedagjan1 <= 4 then
' 1. januar er i uge 1
mandaguge1 = DateAdd("d", -ugedagjan1+1, januar1)
else
' 1. januar er i sidste uge foregående år
mandaguge1 = DateAdd("d", 7-ugedagjan1+1, januar1)
end if
mandagugex = DateAdd("ww", uge-1, mandaguge1)
xdagugex = DateAdd("d", dag-1, mandagugex)
UgeTilDato = xdagugex
End Function
If request.querystring("uge") <> "" Then
uge = request.querystring("uge")
Else
uge = DatePart("ww",date())
End if
If request.querystring("aar") <> "" Then
aar = request.querystring("aar")
Else
aar = Year(Date)
End If
fuge = uge - 1
faar = aar
If fuge < 1 then
fuge = 52
faar = faar - 1
End If
Response.Write"<td width=20% align=left valign=bottom><font color=white face=verdana size=3><A class='speciel2' HREF='skema.asp?reservation=" & request.querystring("reservation") & "&uge=" & fuge & "&aar=" & faar & "'><--Forrige uge </A></font></td>"
%>
<td width="20%" align="left" bgcolor="#999999"><font color="#ffffff"><b><font face="Verdana" size="4">Uge</font><font face="Verdana" size="3"> </font></b>
</font>
<%
If Request.Querystring("uge") <> "" Then
uge = Request.Querystring("uge")
Else
uge = DatePart("ww",date())
End If
Response.Write "<font color=#ffffff face=verdana size=5>"
Response.Write uge
%>
</td>
<%
If request.querystring("uge") <> "" Then
uge = request.querystring("uge")
Else
uge = DatePart("ww",date())
End if
If request.querystring("aar") <> "" Then
aar = request.querystring("aar")
Else
aar = Year(Date)
End If
nuge = uge + 1
naar = aar
If nuge > 52 then
nuge = 1
naar = naar + 1
End If
Response.Write"<td width=35% align=left valign=bottom><font color=white face=verdana size=3><A class='speciel2' HREF='skema.asp?reservation=" & request.querystring("reservation") & "&uge=" & nuge & "&aar=" & naar & "'>Næste uge--></A></font></td>"
%>
</tr>
</table>
<tr>
<td width="8%" bgcolor="#999999"> </td>
<td width="18%" bgcolor="#999999">
<p align="center"><b><font color="#FFFFFF" face="Verdana" size="2">Mandag</font></b><font color="#FFFFFF" face="Verdana" size="2"><br>
<% Response.Write FormatDateTime(UgeTilDato(aar, uge, 1), vbShortDate) %></font></td>
<td width="18%" bgcolor="#999999">
<p align="center"><b><font color="#FFFFFF" face="Verdana" size="2">Tirsdag</font></b><font color="#FFFFFF" face="Verdana" size="2"><br>
<% Response.Write FormatDateTime(UgeTilDato(aar, uge, 2), vbShortDate) %></font></td>
<td width="19%" bgcolor="#999999">
<p align="center"><b><font color="#FFFFFF" face="Verdana" size="2">Onsdag</font></b><font color="#FFFFFF" face="Verdana" size="2"><br>
<% Response.Write FormatDateTime(UgeTilDato(aar, uge, 3), vbShortDate) %></font></td>
<td width="19%" bgcolor="#999999">
<p align="center"><b><font color="#FFFFFF" face="Verdana" size="2">Torsdag</font></b><font color="#FFFFFF" face="Verdana" size="2"><br>
<% Response.Write FormatDateTime(UgeTilDato(aar, uge, 4), vbShortDate) %></font></td>
<td width="19%" bgcolor="#999999">
<p align="center"><b><font color="#FFFFFF" face="Verdana" size="2">Fredag</font></b><font color="#FFFFFF" face="Verdana" size="2"><br>
<% Response.Write FormatDateTime(UgeTilDato(aar, uge, 5), vbShortDate) %></font></td>
</tr>
<!--#include virtual="/assensskolen/skoleweb/conn.asp"-->
<%
lektion = Request.Querystring("lektion")
dag = Request.Querystring("dag")
reservation = Request.Querystring("reservation")
dim SQLdag(7)
SQLdag(1) = "Mandag"
SQLdag(2) = "Tirsdag"
SQLdag(3) = "Onsdag"
SQLdag(4) = "Torsdag"
SQLdag(5) = "Fredag"
SQLdag(6) = "Lørdag"
SQLdag(7) = "Søndag"
dim linkdag(7)
linkdag(1) = "mandag"
linkdag(2) = "tirsdag"
linkdag(3) = "onsdag"
linkdag(4) = "torsdag"
linkdag(5) = "fredag"
linkdag(6) = "lørdag"
linkdag(7) = "søndag"
for lektion = 1 to 8
Response.Write "<tr>"
Response.Write "<td width=8% height=40 align=center bgcolor=#999999><font face=Verdana size=2 color=#ffffff>" & lektion & ". time</font></td>"
for dag = 1 to 5
datoStr = UgeTilDato(aar, uge, 1)
datoStr = Month(datoStr) & "-" & Day(datoStr) & "-" & Right(Year(datoStr),2)
dato = FormatDateTime(UgeTilDato(aar, uge, 1), vbShortDate)
%>
<!--#include virtual="/assensskolen/skoleweb/sql_blokering.asp"-->
<%
set rs = Conn.Execute(strSQL)
if not (rs.EOF or rs.BOF) then
Response.write"<td border=1 bordercolor=#0000FF bordercolordark=#FFFFFF bordercolorlight=#0000F width=18% height=40 bgcolor=red><font face=Verdana size=1 color=#FFFFFF><p align=center>"&rs("tekst")&"</font></td>"
Else
'generer data og HTML kode for (dag,lektion)
strSQL = "SELECT initialer,klasse FROM reserver WHERE reservation='" & request.querystring("reservation") & "' AND dag='" & SQLdag(dag) & "' AND lektion='" & lektion & "' AND uge='" & uge & "' AND aar='" & aar & "'"
set rs = Conn.Execute(strSQL)
if rs.EOF or rs.BOF then
Response.Write"<td width=18% height=40 bgcolor=#F0F8F8><font color=#ffffff><A HREF='reserver_form.asp?aar=" & aar & "&uge=" & uge & "&dag=" & linkdag(dag) & "&lektion=" & lektion & "&reservation=" & reservation &"'><img border=0 src='../images/greenball.gif' alt='Ledig'></font></td>"
Else
Response.Write"<td width=18% height=40 bgcolor=#F0F8F8><b><font color=#ffffff face='verdana' size='2'><img src='../images/redball.gif' alt='Optaget'><img src='../images/blank2.gif'><A class='speciel' HREF='vis_reservation.asp?reservation=" &reservation & "&lektion=" & lektion & "&dag=" & linkdag(dag) & "&uge=" & uge &"&aar=" & aar &"'>"&rs("initialer")&"</A></font></b></td>"
rs.MoveNext
End if
End if
next
Response.Write "</tr>"
next
Conn.Close
Set Conn = Nothing
%>
</table>
<form action="skema.asp" method="post">
<table border="0" width="100%">
<tr>
<td width="33%">
<p align="center"><font face="verdana" size="2" class="speciel">
<% Response.Write "<A class='speciel3' HREF='skema_2.asp?reservation=" & request.querystring("reservation") & "&uge=" & uge & "&aar=" & aar & "'>Skema for hele dagen</A>" %> </font></td>
<td width="33%">
<p align="center"><font face="Verdana" size="2">Gå til uge</font> <input type="text" name="uge" size="3"><input type="submit" value="Send" name="B1"></td>
<td width="34%">
<p align="center"><font face=verdana size=2><A class='speciel3' HREF='../default.asp'>Tilbage
til forsiden</A></font></td>
</tr>
</table>
<input type="hidden" name="reser" value="<%=reservation%>">
<input type="hidden" name="aar" value="<%=aar%>">
<input type="hidden" name="mode" value="change">
</form>
</body>
</html>