03. juli 2004 - 09:40Der er
51 kommentarer og 1 løsning
månedsoversigt som i mylandskalender
Er der nogen der ligger inde med et script, der udskriver en måned som den er vist i en mylandskalenders månedsoversigt. Den skal altså indeholde dag (man,tirs, ...), dato (1,2,3,4...) markering af lørdag og søndag, samt ugenummer.
Hvis ikke der er en der har et script, er jeg også ude efter ideer til hvordan jeg kan gøre det.
<% session.lcid = 1033 dim current_date, first_day, this_date dim counter,days, weeks, current_year dim bgHilite, bgNormal
bgHilite = "#CCCCCC" bgNormal = "#FFFFFF"
' Create an array to display the month names dim month_name(12) month_name(1)="Januar " month_name(2)="Februar " month_name(3)="Marts " month_name(4)="April " month_name(5)="Maj " month_name(6)="Juni " month_name(7)="Juli " month_name(8)="August " month_name(9)="September " month_name(10)="Oktober " month_name(11)="November " month_name(12)="December "
' create a varible for the current date current_date=date()
' create a varible for the current year from the current date current_year=year(current_date)
' create a varible for the current day from the current date this_date=day(current_date)
' create a varible for the current month from the current date month_number=month(current_date)
' create a varible for the first day from the current date first_day=weekday(dateSerial(current_year,month_number,00))
' create a varible for the length of the current month select case month_number
' For the months with 31 days set the end date case "1","3","5","7","8","10","12" last_day=31
' For February set the end date by applying the leap year rules ' if the year is evenly divisable by 4 or ending in 00 divisable by 400
case "2" last_day=28
right_year_divided=current_year/4 if right_year_divided = cint(right_year_divided) then last_day=29 end if
if right(current_year,2)="00" then right_year_divided=current_year/400
if right_year_divided = cint(right_year_divided) then last_day=29 end if ' end check of year values end if ' end check for new century
' All the rest of the months have 30 days case else last_day=30 end select ' end selct of month
%> <html> <title>Kalender</title> <body bgcolor="<%=bgNormal%>"> <table border=1 align=center> <caption><b><%= month_name(month_number) & current_year %></b></caption> <tr><th>Man</th><th>Tir</th><th>Ons</th><th>Tor</th> <th>Fre</th><th>Lør</th><th>Søn</th></tr> <tr> <% ' Loop for the 1st week of the month for counter = 1 to 7 if counter > 5 then %> <td bgcolor="<%=bgHilite%>"> <% else %> <td bgcolor="<%=bgNormal%>"> <% end if
' Check to see what day the first of the month falls on if counter > first_day-1 then
' Count for days days=days+1
' Check to see if the current date is in the 1st week ' if so place it in bold type if days = this_date then response.write ("<b>" & days & "</b>" ) else response.write (days) end if ' End check for current date
end if ' End check for first day of the week %> </td> <% next %> </tr> <% ' Loop for the remaining weeks in the month for weeks = 1 to 5 %> <tr> <% ' Loop of the remaing days of the month for counter = 1 to 7
' Count for days days=days+1
' Write out the date and place in bold if it's the current date if days <= last_day then if counter > 5 then %> <td bgcolor="<%=bgHilite%>"> <% else %> <td bgcolor="<%=bgNormal%>"> <% end if if days=this_date then response.write "<b>" & days & "</b>" else response.write days end if ' End check for current date %></td> <% end if ' End check for end of month next %> </tr><% next %> </table> </body> </html>
'************************************************** ' Loop for the 1st week of the month '************************************************** for counter = 1 to 7 if counter > 5 then '************************************************** 'check for weekend '**************************************************
%> <td <%=TdHilite%>> <% else %> <td <%=tdNormal%>> <% end if
' Check to see what day the first of the month falls on if counter > first_day - 1 then
' Count for days days = days + 1
'************************************************** 'check for current date '**************************************************
' Check to see if the current date is in the 1st week ' if so place it in bold type if days = this_day then response.write ("<b>" & days & "</b>" ) else response.write (days) end if ' End check for current date
end if ' End check for first day of the week %> </td> <% next %> </tr> <%
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 2 to 5 temp_week = temp_week + 1 %> <tr> <td <%=tdWeek%>><%=temp_week%></td> <% ' Loop of the remaing days of the month for counter = 1 to 7
' Count for days days = days + 1
' Write out the date and place in bold if it's the current date if days <= last_day then if counter > 5 then '************************************************** 'check for weekend '************************************************** %> <td <%=tdHilite%>> <% else %> <td <%=tdNormal%>> <% end if '************************************************** 'check for current date '************************************************** if days=this_day then response.write "<b>" & days & "</b>" else response.write days end if ' End check for current date %> </td> <% end if ' End check for end of month next %> </tr><% next %> </table> </body> </html>
' Create an array to display the month names dim month_name(12) month_name(1)="Januar " month_name(2)="Februar " month_name(3)="Marts " month_name(4)="April " month_name(5)="Maj " month_name(6)="Juni " month_name(7)="Juli " month_name(8)="August " month_name(9)="September " month_name(10)="Oktober " month_name(11)="November " month_name(12)="December "
' create a variable for the current date current_date=date()
' create a variable for the current year from the current date this_year=year(current_date)
' create a variable for the current day from the current date this_day=day(current_date)
' create a variable for the current day number from the current date assuming monday is the first day day_of_week = DatePart("W", current_date, vbMonday)
' create a variable for the current week from the current date this_week = DatePart("WW", current_date)
' create a variable for the current month from the current date this_month=month(current_date)
' create a variable for the first day from the current date first_day = weekday(dateSerial(this_year, this_month ,00))
' create a varible for the length of the current month select case this_month
' For the months with 31 days set the end date case "1","3","5","7","8","10","12" last_day = 31
' For February set the end date by applying the leap year rules ' if the year is evenly divisable by 4 or ending in 00 divisable by 400
case "2" last_day = 28
right_year_divided=this_year/4
if right_year_divided = cint(right_year_divided) then last_day = 29 end if
if right(this_year,2)="00" then right_year_divided=this_year/400
if right_year_divided = cint(right_year_divided) then last_day = 29 end if ' end check of year values end if ' end check for new century
' All the rest of the months have 30 days case else last_day = 30 end select ' end selct of month
'************************************************** ' Loop for the 1st week of the month '************************************************** for counter = 1 to 7 if counter > 5 then '************************************************** 'check for weekend '**************************************************
%> <td <%=TdHilite%>> <% else %> <td <%=tdNormal%>> <% end if
' Check to see what day the first of the month falls on if counter > first_day - 1 then
' Count for days days = days + 1
'************************************************** 'check for current date '**************************************************
' Check to see if the current date is in the 1st week ' if so place it in bold type if days = this_day then response.write ("<b>" & days & "</b>" ) else response.write (days) end if ' End check for current date
end if ' End check for first day of the week %> </td> <% next %> </tr> <%
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 2 to 5 temp_week = temp_week + 1 %> <tr> <td <%=tdWeek%>><%=temp_week%></td> <% ' Loop of the remaing days of the month for counter = 1 to 7
' Count for days days = days + 1
' Write out the date and place in bold if it's the current date if days <= last_day then if counter > 5 then '************************************************** 'check for weekend '************************************************** %> <td <%=tdHilite%>> <% else %> <td <%=tdNormal%>> <% end if '************************************************** 'check for current date '************************************************** if days=this_day then response.write "<b>" & days & "</b>" else response.write days end if ' End check for current date %> </td> <% end if ' End check for end of month next %> </tr><% next %> </table> </body> </html>
' create a variable for the current date current_date=date()
' create a variable for the current year from the current date this_year=year(current_date)
' create a variable for the current day from the current date this_day=day(current_date)
' create a variable for the current day number from the current date assuming monday is the first day day_of_week = DatePart("W", current_date, vbMonday)
' create a variable for the current week from the current date this_week = DatePart("WW", current_date)
' create a variable for the current month from the current date this_month=month(current_date)
' create a variable for the first day from the current date first_day = weekday(dateSerial(this_year, this_month ,00))
' create a variable for the length of the current month select case this_month
' For the months with 31 days set the end date case "1","3","5","7","8","10","12" last_day = 31
' For February set the end date by applying the leap year rules ' if the year is evenly divisable by 4 or ending in 00 divisable by 400
case "2" last_day = 28
right_year_divided=this_year/4
if right_year_divided = cint(right_year_divided) then last_day = 29 end if
if right(this_year,2)="00" then right_year_divided=this_year/400
if right_year_divided = cint(right_year_divided) then last_day = 29 end if ' end check of year values end if ' end check for new century
' All the rest of the months have 30 days case else last_day = 30 end select ' end selct of month
'************************************************** ' Loop for the first week '************************************************** for counter = 1 to 7
' Check to see what day the first of the month falls on if counter > first_day - 1 then
' Count for days days = days + 1 %> <tr> <% if counter = first_day then %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></td> <% elseif counter = 1 then ' new week ' write out week number %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></td> <% elseif counter = 6 then ' grey the first cell %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% elseif counter = 7 then ' sunday - grey out cell %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;"> </td> <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"> </td> <% else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if ' End check for first day of the week next
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 2 to 5
temp_week = temp_week + 1
'************************************************** ' Loop the week '************************************************** for counter = 1 to 7
if days <= last_day then
if days < last_day then ' increment days days = days + 1 end if %> <tr> <% if counter = 1 then 'write out week number %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></td> <% elseif counter = 6 then %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% elseif counter = 7 then ' sunday - grey out cell %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;"> </td> <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"> </td> <% else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if next next %>
Jeg har lige kigget lidt nærmere på det, og det ser ud som om at den altid skriver den sidste uge helt ud, også selvom det ikke er en del af måneden, så ex i denne måned hedder den sidste lørdag og søndag den 31, fordi søndagen først er med i næste måned.
' create a variable for the current date current_date=date()
' create a variable for the current year from the current date this_year=year(current_date)
' create a variable for the current day from the current date this_day=day(current_date)
' create a variable for the current day number from the current date assuming monday is the first day day_of_week = DatePart("W", current_date, vbMonday)
' create a variable for the current week from the current date this_week = DatePart("WW", current_date)
' create a variable for the current month from the current date this_month=month(current_date)
' create a variable for the first day from the current date first_day = weekday(dateSerial(this_year, this_month ,00))
' create a variable for the length of the current month select case this_month
' For the months with 31 days set the end date case "1","3","5","7","8","10","12" last_day = 31
' For February set the end date by applying the leap year rules ' if the year is evenly divisable by 4 or ending in 00 divisable by 400
case "2" last_day = 28
right_year_divided=this_year/4
if right_year_divided = cint(right_year_divided) then last_day = 29 end if
if right(this_year,2)="00" then right_year_divided=this_year/400
if right_year_divided = cint(right_year_divided) then last_day = 29 end if ' end check of year values end if ' end check for new century
' All the rest of the months have 30 days case else last_day = 30 end select ' end selct of month
'************************************************** ' Loop for the first week '************************************************** for counter = 1 to 7
' Check to see what day the first of the month falls on if counter > first_day - 1 then
' Count for days days = days + 1 %> <tr> <% if counter = first_day then %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></td> <% elseif counter = 1 then ' new week ' write out week number %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></td> <% elseif counter = 6 then ' grey the first cell %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% elseif counter = 7 then ' sunday - grey out cell %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;"> </td> <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"> </td> <% else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if ' End check for first day of the week next
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 2 to 5
temp_week = temp_week + 1
'************************************************** ' Loop the week '************************************************** for counter = 1 to 7
' increment days days = days + 1
if days <= last_day then
%> <tr> <% if counter = 1 then 'write out week number %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></td> <% elseif counter = 6 then %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% elseif counter = 7 then ' sunday - grey out cell %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;"> </td> <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"> </td> <% else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if next next %>
'************************************************** ' Loop the week '************************************************** for counter = 1 to 7
' increment days days = days + 1
if days <= last_day then
'snip
'increment days var efter linjen if days <= og den er flyttet udenfor. den fik optalt en dag for meget - så der var 32 dage i en måned ;o) og det går jo ikke.
' create a variable for the current date current_date=date()
' create a variable for the current year from the current date this_year=year(current_date)
' create a variable for the current day from the current date this_day=day(current_date)
' create a variable for the current day number from the current date assuming monday is the first day day_of_week = DatePart("W", current_date, vbMonday)
' create a variable for the current week from the current date this_week = DatePart("WW", current_date)
' create a variable for the current month from the current date If Request("month") = "" Then this_month=month(current_date) Else this_month = Request("month") End If
' create a variable for the first day from the current date first_day = weekday(dateSerial(this_year, this_month ,00))
' create a variable for the length of the current month select case this_month
' For the months with 31 days set the end date case "1","3","5","7","8","10","12" last_day = 31
' For February set the end date by applying the leap year rules ' if the year is evenly divisable by 4 or ending in 00 divisable by 400
case "2" last_day = 28
right_year_divided=this_year/4
if right_year_divided = cint(right_year_divided) then last_day = 29 end if
if right(this_year,2)="00" then right_year_divided=this_year/400
if right_year_divided = cint(right_year_divided) then last_day = 29 end if ' end check of year values end if ' end check for new century
' All the rest of the months have 30 days case else last_day = 30 end select ' end selct of month
'************************************************** ' Loop for the first week '************************************************** for counter = 1 to 7
' Check to see what day the first of the month falls on if counter > first_day - 1 then
' Count for days days = days + 1 %> <tr> <% if counter = first_day then %> <td width="20" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%></td> <td width="37" style="border-bottom: solid 1px #000000;"><%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" align="right" style="border-bottom: solid 1px #000000;"><b><%=temp_week%></b></td> <% elseif counter = 1 then ' new week ' write out week number %> <td width="20" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%></td> <td width="37" style="border-bottom: solid 1px #000000;"><%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" align="right" style="border-bottom: solid 1px #000000;"><b><%=temp_week%></b></td> <% elseif counter = 6 then ' grey the first cell %> <td bgcolor="#CCCCCC" width="20" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%></td> <td bgcolor="#CCCCCC" width="37" style="border-bottom: solid 1px #000000;"><%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% elseif counter = 7 then ' sunday - grey out cell %> <td bgcolor="#CCCCCC" width="20" style="border-bottom: solid 2px #000000;"><%=day_name(counter)%></td> <td bgcolor="#CCCCCC" width="37" style="border-bottom: solid 2px #000000;"><%=days%></td> <td bgcolor="#CCCCCC" style="border-bottom: solid 2px #000000;"> </td> <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 2px #000000;"> </td> <% else ' no grey on normal and saturday %> <td width="20" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%></td> <td width="37" style="border-bottom: solid 1px #000000;"><%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if ' End check for first day of the week next
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 2 to 5
temp_week = temp_week + 1
'************************************************** ' Loop the week '************************************************** for counter = 1 to 7 ' increment days days = days + 1 if days <= last_day then
if days < last_day then
end if %> <tr> <% if counter = 1 then 'write out week number %> <td width="20" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%></td> <td width="37" style="border-bottom: solid 1px #000000;"><%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" align="right" style="border-bottom: solid 1px #000000;"><b><%=temp_week%></b></td> <% elseif counter = 6 then %> <td bgcolor="#CCCCCC" width="20" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%></td> <td bgcolor="#CCCCCC" width="37" style="border-bottom: solid 1px #000000;"><%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% elseif counter = 7 then ' sunday - grey out cell %> <td bgcolor="#CCCCCC" width="20" style="border-bottom: solid 2px #000000;"><%=day_name(counter)%></td> <td bgcolor="#CCCCCC" width="37" style="border-bottom: solid 2px #000000;"><%=days%></td> <td bgcolor="#CCCCCC" style="border-bottom: solid 2px #000000;"> </td> <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 2px #000000;"> </td> <% else ' no grey on normal and saturday %> <td width="20" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%></td> <td width="37" style="border-bottom: solid 1px #000000;"><%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if next next %>
' create a variable for the current date current_date=date()
' create a variable for the current year from the current date this_year=year(current_date)
' create a variable for the current day from the current date this_day=day(current_date)
' create a variable for the current day number from the current date assuming monday is the first day day_of_week = DatePart("W", current_date, vbMonday)
' create a variable for the current week from the current date this_week = DatePart("WW", current_date)
' create a variable for the current month from the current date this_month=month(current_date)
' create a variable for the first day from the current date first_day = weekday(dateSerial(this_year, this_month ,00))
' create a variable for the length of the current month select case this_month
' For the months with 31 days set the end date case "1","3","5","7","8","10","12" last_day = 31
' For February set the end date by applying the leap year rules ' if the year is evenly divisable by 4 or ending in 00 divisable by 400
case "2" last_day = 28
right_year_divided=this_year/4
if right_year_divided = cint(right_year_divided) then last_day = 29 end if
if right(this_year,2)="00" then right_year_divided=this_year/400
if right_year_divided = cint(right_year_divided) then last_day = 29 end if ' end check of year values end if ' end check for new century
' All the rest of the months have 30 days case else last_day = 30 end select ' end selct of month
elseif DatePart("W", this_year & "-" & this_month & "-" & formatNumber(days,0,true,false,false), vbMonday) = 6 then ' grey the first cell %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% elseif DatePart("W", this_year & "-" & this_month & "-" & formatNumber(days,0,true,false,false), vbMonday) = 7 then ' sunday - grey out cell %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;"> </td> <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"> </td> <% else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if ' End check for first day of the week next
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 2 to 5
temp_week = temp_week + 1
'************************************************** ' Loop the week '************************************************** for counter = 1 to 7
' increment days days = days + 1
if days <= last_day then
%> <tr> <% if counter = 1 then 'write out week number %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></td> <% elseif counter = 6 then %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% elseif counter = 7 then ' sunday - grey out cell %> <td bgcolor="#CCCCCC" width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;"> </td> <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"> </td> <% else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if next next %>
ikke lige nu - jeg kan ikke forstå at systemet returnerer en forkert uge for den første dag i måneden og jeg har på fornemmelsen at det hænger sammen med august problemet men jeg kan ikke lige gennemskue hvorfor det går galt
' create a variable for the current date current_date=date()
' create a variable for the current year from the current date this_year=year(current_date)
' create a variable for the current month from the current date this_month=month(current_date)
' create a variable for the current day from the current date this_day=day(current_date)
' create a variable for the current week from the current date this_week = DatePart("WW", current_date)
' create a variable for the week number which the first day of the month is part of if len(this_month) = 1 then start_week = DatePart("WW", this_year & "-0" & this_month & "-" & "01",vbmonday) else start_week = DatePart("WW", this_year & "-" & this_month & "-" & "01",vbmonday) end if
' create a variable for the current day number from the current date assuming monday is the first day day_of_week = DatePart("W", current_date, vbMonday)
' create a variable for the first day from the current date first_day = weekday(dateSerial(this_year, this_month, 00))
' create a variable for the length of the current month select case this_month
' For the months with 31 days set the end date case "1","3","5","7","8","10","12" 'january 'march 'may 'july 'august 'october 'december last_day = 31
' For February set the end date by applying the leap year rules ' if the year is evenly divisable by 4 or ending in 00 divisable by 400
case "2" 'february last_day = 28
right_year_divided=this_year/4
if right_year_divided = cint(right_year_divided) then last_day = 29 end if
if right(this_year,2)="00" then right_year_divided=this_year/400
if right_year_divided = cint(right_year_divided) then last_day = 29 end if ' end check of year values end if ' end check for new century
' All the rest of the months have 30 days case "4","6","9","11" 'april 'june 'september 'november last_day = 30
'************************************************** ' Loop for the first week '************************************************** for counter = 1 to 7 ' Check to see what day the first of the month falls on if counter > first_day - 1 then
' Count for days days = days + 1 %> <tr> <% if counter = first_day or counter = 1 then
else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if ' End check for first day of the week next
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 1 to 5
start_week = start_week + 1
'************************************************** ' Loop the week '************************************************** for counter = 1 to 7
else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if ' End check for first day of the week next next %>
cool, har lige tjekket det , og det ser fint ud i år 2004, men når man kommer til 2005, så skriver den uge 1 ved den 1 og 2 der høre til uge 53 fra året før, så der bliver alle ugerne forskubbet.
Jeg har dykket så meget ned i problemet, da vbcoder (trusted partner) har fat og btw også har fået koden til min kalender. VBcoder burde ved et kig i koden se hvordan opbygningen skal foretages og hvodan man regner ugenr rigtig ud. Jeg kan godt pille denne kodestump ud til dig - hjemme fra.
--> hnteknik - jeg har dykket i koden og fundet funktionen omkring ugenummeret - jeg er en klovn til jscript ;-( - men har dog tænkt en smule.
--> moejensen - lige i øjeblikket er jeg voldsomt hængt op til anden side så jeg har simpelthen ikke haft tid til at prøve at oversætte ugefunktionen fra jcript til vbscript.
>>moejensen jeg er selv hængt op af flere større projekter, så jeg ahr ikke engang haft tid til at rette min MYSQL klamamse i eget script (genere en rigtig MYSQL dato ala 2004-09-20 -alt virker i Access). Vi må se, hvad VBCoder siger.
>> mskjoldp - overset dit indlæg i spamkassen. Muligheden er til stede for ussel mammon. Skriv evt. til mig på hnteknikxyz@post4.tele.dk fjern xyz
jeg har fundet en løsning på uge problematikken men det var ikke nemt da alle de mulighededer jeg kunne finde alle returnerede uge 1 for de første datoer i den første måned i året.
jeg dog en artikel på activedeveloper som beskriver hvordan man formulerer hvordan den første og den sidste uge defineres.
Ud fra det er der blevet noget kode til som laver den rigtige uge altid.
koden til hele siden er her og den har kostet megen hovedbrud.
<% option explicit
session.lcid = 1033
'extracted data dim current_date, first_day, this_day, this_week, this_month, this_year, last_day, day_of_week
' counters dim counter, wdays, weeks, start_week, week_calc, num_weeks_in_year, right_year_divided
' Create an array to display the month names dim month_name(12) month_name(1)="JANUAR " month_name(2)="FEBRUAR " month_name(3)="MARTS " month_name(4)="APRIL " month_name(5)="MAJ " month_name(6)="JUNI " month_name(7)="JULI " month_name(8)="AUGUST " month_name(9)="SEPTEMBER " month_name(10)="OKTOBER " month_name(11)="NOVEMBER " month_name(12)="DECEMBER "
' create a variable for the current date current_date=date()
' create a variable for the current year from the current date this_year=year(current_date)
' create a variable for the current month from the current date this_month=month(current_date)
' create a variable for the current day from the current date this_day=day(current_date)
' create a variable for the current week from the current date this_week = DatePart("WW", current_date)
' create a variable for the week number which the first day of the month is part of start_week = weekNumber (dateSerial(this_year, this_month , 1))
' create a variable for the current day number from the current date assuming monday is the first day day_of_week = DatePart("W", current_date, vbMonday)
' create a variable for the first day from the current date first_day = weekday(dateSerial(this_year, this_month, 00))
' create a variable for the length of the current month select case this_month
' For the months with 31 wdays set the end date case "1","3","5","7","8","10","12" 'january 'march 'may 'july 'august 'october 'december last_day = 31
' For February set the end date by applying the leap year rules ' if the year is evenly divisable by 4 or ending in 00 divisable by 400
case "2" 'february last_day = 28
right_year_divided=this_year/4
if right_year_divided = cint(right_year_divided) then last_day = 29 end if
if right(this_year,2)="00" then right_year_divided=this_year/400
if right_year_divided = cint(right_year_divided) then last_day = 29 end if ' end check of year values end if ' end check for new century
' All the rest of the months have 30 wdays case "4","6","9","11" 'april 'june 'september 'november last_day = 30
'************************************************** ' Loop for the first week '************************************************** for counter = 1 to 7 ' Check to see what day the first of the month falls on if counter > first_day - 1 then
' Count for wdays wdays = wdays + 1 %> <tr> <% if counter = first_day or counter = 1 then
else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=wdays%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if ' End check for first day of the week next
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 1 to 5
if start_week = 53 then start_week = 1 else start_week = start_week +1 end if
'************************************************** ' Loop the week '************************************************** for counter = 1 to 7
else ' no grey on normal and saturday %> <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=wdays%></td> <td style="border-bottom: solid 1px #000000;"> </td> <td width="42" style="border-bottom: solid 1px #000000;"> </td> <% end if %> </tr> <% end if ' End check for first day of the week next next %>
</table>
</body> </html> <%Public Function WeekNumber(InDate) Dim v1 Dim v2 Dim v3 Dim v4 Dim v5 Dim v6 Dim v7 v1=Days(InDate) v4=Weekday(DateSerial(Year(InDate),1,1),vbUseSystemDayOfWeek)-1 v5=Weekday(DateSerial(Year(InDate),12,31),vbUseSystemDayOfWeek)-1 v2=7-(v4-1) v3=7-(v5-1) If v4=4 Or v5=4 Then v7=True Else v7=False v6=(v1-v2-4)/7 If v2=>4 Then WeekNumber=cint(v6)+2 Else WeekNumber=cint(v6)+1 If WeekNumber>52 And Not v7 Then WeekNumber=1 If WeekNumber=0 Then WeekNumber=WeekNumber(DateSerial(Year(InDate)-1,12,31)) End Function Public Function Days(v1) Days=v1-DateSerial(Year(v1),1,0) End Function%>
jeg fundet en lille buk i systemet som gør at der i nogle tilfælde skrives forkert ugenumre på. bukken kommer kun frem i januar måned.
Denne kode
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 1 to 5
if start_week = 53 then start_week = 1 else start_week = start_week +1 end if
skal erstattes med denne
'************************************************** ' Loop for the remaining weeks in the month '************************************************** for weeks = 1 to 5
Hvis jeg nu skal indsæte nogle aktiviteter i kalenderen, hvor i koden skal jeg så sette dem ind. Aktiviteterne er placeret i en db, hvor datoen og aktiviteten også findes?
meget lækker kalender men når jeg smider koden ind i en asp fil får jeg søndag den 1 jan 2006 til at være uge 52. mandagen starter så med uge 53, manda den 9. uge 1 osv.osv
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.