Avatar billede moejensen Nybegynder
03. juli 2004 - 09:40 Der 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.
Avatar billede moejensen Nybegynder
03. juli 2004 - 10:52 #1
Alternativt, kan jeg også nøjes med følgende asp funktioner:

antal dage i en måned
uger i en måned
dage i måneden

Så kan jeg lave resten selv.
Avatar billede vbcoder Nybegynder
03. juli 2004 - 13:56 #2
mangler kun uge numre

<%
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>
Avatar billede vbcoder Nybegynder
03. juli 2004 - 13:57 #3
jeg ved ikke hvilket layout du ref. til
Avatar billede vbcoder Nybegynder
03. juli 2004 - 15:53 #4
den her er med ugenumre - der skal nok rettes lidt til i forhold til perioden omkring nytår

<%
option explicit
session.lcid = 1033
'extracted data
dim current_date, first_day, this_day, this_week, this_month, this_year, last_day
' counters
dim counter, days, weeks, temp_week, week_calc
'table cell layout
dim tbHeader, tdHilite, tdNormal, tdWeek
'color
dim bgNormal

bgNormal = "#FFFFFF"
tbHeader = "bgcolor='#CCCCCC' align='center'"
tdHilite = "bgcolor='#CCCCCC' width='50px' align='center'"
tdNormal = "bgcolor='#FFFFFF' width='50px' align='center'"
tdWeek = "bgcolor='#CCFFCC' width='50px' align='center'"


' 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 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

week_calc = cint(this_day) / 7
this_week = cint(this_week)

if week_calc <= 7 then
  temp_week = this_week
elseif week_calc <= 14 then
  temp_week = this_week - 1
elseif week_calc <= 21 then
  temp_week = this_week - 2
elseif week_calc <= 28 then
  temp_week = this_week - 3
elseif week_calc <= 31 then
  temp_week = this_week - 4
end if

%>
<html>
<title>Kalender</title>
<body bgcolor="<%=bgNormal%>">
<table border=1 align=center>
<caption><b><%= month_name(this_month) & this_year %></b></caption>
<tr <%=tbHeader%>>
  <th>Uge</th><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>
  <td <%=tdWeek%>><%=temp_week%></td>
<%

'**************************************************
' Loop for the 1st week of the month
'**************************************************
for counter = 1 to 7
    if counter > 5 then
    '**************************************************
    'check for weekend
    '**************************************************

    %>
      <td <%=TdHilite%>>&nbsp;
    <%
    else
    %>
      <td <%=tdNormal%>>&nbsp;
    <%
    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%>>&nbsp;
      <%
      else
      %>
        <td <%=tdNormal%>>&nbsp;
      <%
      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>
Avatar billede vbcoder Nybegynder
03. juli 2004 - 16:39 #5
det med ugerne det duer ikke - har fundet ud af det filmen knækker for koden når den skal skriver ugerne på - hmme - gider ikke lege med det lige nu
Avatar billede vbcoder Nybegynder
03. juli 2004 - 18:28 #6
løste ugeproblemet:

<%
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, days, weeks, temp_week, week_calc, num_weeks_in_year, right_year_divided
'table cell layout
dim tbHeader, tdHilite, tdNormal, tdWeek
'color
dim bgNormal

bgNormal = "#FFFFFF"
tbHeader = "bgcolor='#CCCCCC' align='center'"
tdHilite = "bgcolor='#CCCCCC' width='50px' align='center'"
tdNormal = "bgcolor='#FFFFFF' width='50px' align='center'"
tdWeek = "bgcolor='#CCFFCC' width='50px' align='center'"


' 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

temp_week = DatePart("WW", this_year & "-" & this_month & "-" & "01")

%>
<html>
<title>Kalender</title>
<body bgcolor="<%=bgNormal%>">
<table border=1 align=center>
<caption><b><%= month_name(this_month) & this_year %></b></caption>
<tr <%=tbHeader%>>
  <th>Uge</th><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>
  <td <%=tdWeek%>><%=temp_week%></td>
<%

'**************************************************
' Loop for the 1st week of the month
'**************************************************
for counter = 1 to 7
    if counter > 5 then
    '**************************************************
    'check for weekend
    '**************************************************

    %>
      <td <%=TdHilite%>>&nbsp;
    <%
    else
    %>
      <td <%=tdNormal%>>&nbsp;
    <%
    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%>>&nbsp;
      <%
      else
      %>
        <td <%=tdNormal%>>&nbsp;
      <%
      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>
Avatar billede moejensen Nybegynder
04. juli 2004 - 14:20 #7
Det ser rigtig godt ud, men den måde jeg gerne ville have det vist på, er på den lodrette led, så alle dagene står nedaf.

Jeg har lavet et eksempel du kan se her:


<head>
<meta http-equiv="Content-Language" content="da">
</head>

<p align="center">&nbsp;</p>
<table border="0" width="47%" id="table1" cellspacing="0">
    <tr>
        <td width="57" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
        <td align="center" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;"><b>JULI 2004 - 7. MÅNED</b></td>
        <td width="42" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
    </tr>
    <tr>
        <td width="57" style="border-bottom: solid 1px #000000;">T 1</td>
        <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
        <td width="42" style="border-bottom: solid 1px #000000;">27</td>
    </tr>
    <tr>
        <td width="57" style="border-bottom: solid 1px #000000;">F 2</td>
        <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
        <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
    </tr>
    <tr>
        <td width="57" bgcolor="#C0C0C0" style="border-bottom: solid 1px #000000;">L 3</td>
        <td bgcolor="#FFFFFF" style="border-bottom: solid 1px #000000;">&nbsp;</td>
        <td width="42" bgcolor="#FFFFFF" style="border-bottom: solid 1px #000000;">&nbsp;</td>
    </tr>
    <tr>
        <td width="57" bgcolor="#C0C0C0" style="border-bottom: solid 2px #000000;">S 5</td>
        <td bgcolor="#C0C0C0" style="border-bottom: solid 2px #000000;">&nbsp;</td>
        <td width="42" bgcolor="#C0C0C0" style="border-bottom: solid 2px #000000;">&nbsp;</td>
    </tr>
    <tr>
        <td width="57" style="border-bottom: solid 1px #000000;">M 6</td>
        <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
        <td width="42" style="border-bottom: solid 1px #000000;">28</td>
    </tr>
    <tr>
        <td width="57" style="border-bottom: solid 1px #000000;">T 7</td>
        <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
        <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
    </tr>
    <tr>
        <td width="57" style="border-bottom: solid 1px #000000;">O 8</td>
        <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
        <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
    </tr>
    <tr>
        <td width="57" style="border-bottom: solid 1px #000000;">T 9</td>
        <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
        <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
    </tr>
    <tr>
        <td width="57" style="border-bottom: solid 1px #000000;">F 10</td>
        <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
        <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
    </tr>
    <tr>
        <td width="57" bgcolor="#C0C0C0" style="border-bottom: solid 1px #000000;">L 11</td>
        <td bgcolor="#FFFFFF" style="border-bottom: solid 1px #000000;">&nbsp;</td>
        <td width="42" bgcolor="#FFFFFF" style="border-bottom: solid 1px #000000;">&nbsp;</td>
    </tr>
    <tr>
        <td width="57" bgcolor="#C0C0C0" style="border-bottom: solid 2px #000000;">S 12</td>
        <td bgcolor="#C0C0C0" style="border-bottom: solid 2px #000000;">&nbsp;</td>
        <td width="42" bgcolor="#C0C0C0" style="border-bottom: solid 2px #000000;">&nbsp;</td>
    </tr>
    </table>
Avatar billede moejensen Nybegynder
04. juli 2004 - 14:21 #8
er det muligt at sætte det sammen med det du har lavet?
Avatar billede vbcoder Nybegynder
04. juli 2004 - 15:54 #9
<%
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, days, weeks, temp_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 "

dim day_name(7)
day_name(1)="M "
day_name(2)="T "
day_name(3)="O "
day_name(4)="T "
day_name(5)="F "
day_name(6)="L "
day_name(7)="S "

' 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

temp_week = DatePart("WW", this_year & "-" & this_month & "-" & "01")

%>
<html>
<title>Kalender</title>
<head>
<meta http-equiv="Content-Language" content="da">
</head>

<body>

<p align="center">&nbsp;</p>
<table border="0" width="70%" id="table1" cellspacing="0" align="center">
    <%
    'page header start
    %>
    <tr>
        <td width="57" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
        <td align="center" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;"><b><%=month_name(this_month)%> <%=this_year%> - <%=this_month%>. MÅNED</b></td>
        <td width="42" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
    </tr>
    <%
    'page header end

    '**************************************************
    ' 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;">&nbsp;</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;">&nbsp;</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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <%
            end if
            %>
          </tr>           
        <%     
        end if 
      next
    next
    %>

</table>
</body>
</html>
Avatar billede moejensen Nybegynder
04. juli 2004 - 21:50 #10
Det er sku for lækketr :-)

tusind tak for hjælpen.

Laver du lige et svar.
Avatar billede moejensen Nybegynder
04. juli 2004 - 22:15 #11
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.
Avatar billede hnteknik Novice
04. juli 2004 - 22:33 #12
Lige inde fra vesterhavshytten og tømme postkassen.
Var det sådan en kalender: http://www.web4it.dk/kalender/

Henrik
Avatar billede moejensen Nybegynder
04. juli 2004 - 22:38 #13
Ja, det var sådan set lige sådan en, men nu har jeg den jo næsten fra vbcoder.

Er det en kalender du har koden til, så vil jeg da meget gerne se nærmere på den?
Avatar billede hnteknik Novice
04. juli 2004 - 23:11 #14
Yep - jeg har koden og brugt en del tid på at få det tila t hænge sammen.
Lad os se, om VBcoder ikke får Jeppe i kassen.
Avatar billede vbcoder Nybegynder
05. juli 2004 - 07:50 #15
--> hn --> det ser da rigtigt godt ud

det ene script havde jeg - det skulle oversættes - jeg synes nu bare det var sjovt at prøve ;o)

--> moe --> jeg kigger lidt på det senere - har nemlig dårligt tid i dag ;o)
Avatar billede vbcoder Nybegynder
05. juli 2004 - 07:57 #16
jæ' ku' id' la' vær'

<%
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, days, weeks, temp_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 "

dim day_name(7)
day_name(1)="M "
day_name(2)="T "
day_name(3)="O "
day_name(4)="T "
day_name(5)="F "
day_name(6)="L "
day_name(7)="S "

' 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

temp_week = DatePart("WW", this_year & "-" & this_month & "-" & "01")

%>
<html>
<title>Kalender</title>
<head>
<meta http-equiv="Content-Language" content="da">
</head>

<body>

<p align="center">&nbsp;</p>
<table border="0" width="70%" id="table1" cellspacing="0" align="center">
    <%
    'page header start
    %>
    <tr>
        <td width="57" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
        <td align="center" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;"><b><%=month_name(this_month)%> <%=this_year%> - <%=this_month%>. MÅNED</b></td>
        <td width="42" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
    </tr>
    <%
    'page header end

    '**************************************************
    ' 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;">&nbsp;</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;">&nbsp;</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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <%
            end if
            %>
          </tr>           
        <%     
        end if 
      next
    next
    %>

</table>
</body>
</html>
Avatar billede moejensen Nybegynder
05. juli 2004 - 07:57 #17
det er helt fint :-)
Avatar billede moejensen Nybegynder
05. juli 2004 - 07:59 #18
okay det var hurtigt, kan du skrive hvor du har rettet?

Har nemlig rettet lidt til at farverne i den tidligere version.
Avatar billede vbcoder Nybegynder
05. juli 2004 - 07:59 #19
hn -> jeg er i gang med et booking system her i firmaet og den kalender er bare for sej. du har vist min mail
Avatar billede vbcoder Nybegynder
05. juli 2004 - 08:01 #20
det sidste loop

'snip

      '**************************************************
      ' 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.
Avatar billede moejensen Nybegynder
05. juli 2004 - 08:25 #21
så ser det ud til at virke, endnu engang tak for hjælpen.
Avatar billede moejensen Nybegynder
05. juli 2004 - 08:42 #22
Jeg fandt lige et par småting mere.

Hvis Lørdag eller Søndag er den første dag i måneden, så bliver de ikke farvet grå

I Maj mangler den 31.

I august, får den lagt en uge for meget til, og så viser den kun 29 dage :-(

Jeg har lige sat koden ind:

<%
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, days, weeks, temp_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 "

dim day_name(7)
day_name(1)="M "
day_name(2)="T "
day_name(3)="O "
day_name(4)="T "
day_name(5)="F "
day_name(6)="L "
day_name(7)="S "

' 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

temp_week = DatePart("WW", this_year & "-" & this_month & "-" & "01")

%>
<html>
<title>Kalender</title>
<head>
<meta http-equiv="Content-Language" content="da">
</head>

<body>

<p align="center"><a href="default.asp?month=<%=this_month - 1%>"><%response.write(month_name(this_month - 1))%></a> &nbsp;&nbsp;<%response.write(month_name(this_month))%>&nbsp;&nbsp;<a href="default.asp?month=<%=this_month + 1%>"><%response.write(month_name(this_month + 1))%></a></p>

<table border="0" width="70%" cellspacing="0" align="center" style="font-family: verdana; font-size: 14px;">
    <tr>
        <td width="57" colspan="2" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
        <td align="center" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;"><b><%=month_name(this_month)%> <%=this_year%> - <%=this_month%>. MÅNED</b></td>
        <td width="42" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
    </tr>
    <%
    'page header end

    '**************************************************
    ' 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;">&nbsp;</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;">&nbsp;</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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 2px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 2px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <%
            end if
            %>
          </tr>           
        <%     
        end if 
      next
    next
    %>

</table>
</body>
</html>
Avatar billede vbcoder Nybegynder
05. juli 2004 - 09:19 #23
<%
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, days, weeks, temp_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 "

dim day_name(7)
day_name(1)="M "
day_name(2)="T "
day_name(3)="O "
day_name(4)="T "
day_name(5)="F "
day_name(6)="L "
day_name(7)="S "

' 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

temp_week = DatePart("WW", this_year & "-" & this_month & "-" & "01")

%>
<html>
<title>Kalender</title>
<head>
<meta http-equiv="Content-Language" content="da">
</head>

<body>

<p align="center">&nbsp;</p>
<table border="0" width="70%" id="table1" cellspacing="0" align="center">
    <%
    'page header start
    %>
    <tr>
        <td width="57" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
        <td align="center" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;"><b><%=month_name(this_month)%> <%=this_year%> - <%=this_month%>. MÅNED</b></td>
        <td width="42" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
    </tr>
    <%
    'page header end

    '**************************************************
    ' 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
           
              if 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;">&nbsp;</td>
                  <td width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></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;">&nbsp;</td>
                <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></td>
                <%
              else
              %>
                <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%> <%=days%></td>
                <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;"><%=temp_week%></td>
              <%           
              end if
           
            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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <%
            end if
            %>
          </tr>           
        <%     
        end if 
      next
    next
    %>

</table>
</body>
</html>
Avatar billede moejensen Nybegynder
05. juli 2004 - 09:41 #24
så kom lørdag og søndag på, så magler jeg bare:

I Maj mangler den 31.

I august, får den lagt en uge for meget til, og så viser den kun 29 dage :-(
Avatar billede hnteknik Novice
05. juli 2004 - 20:42 #25
VBcoder - IOU - CUM
Avatar billede vbcoder Nybegynder
06. juli 2004 - 09:50 #26
og februar begynder med en forkert uge
Avatar billede moejensen Nybegynder
06. juli 2004 - 10:53 #27
vbcoder, er det noget du har en løsning på :-)
Avatar billede vbcoder Nybegynder
06. juli 2004 - 11:13 #28
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
Avatar billede moejensen Nybegynder
06. juli 2004 - 11:38 #29
okay, jeg venter og håber du finder en løsning. Ellers kan det være hnteknik kan give en hånd, han har jo sikkert løst problemet før i hans udgange.
Avatar billede vbcoder Nybegynder
06. juli 2004 - 11:45 #30
<%
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, days, 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 "

dim day_name(7)
day_name(1)="M "
day_name(2)="T "
day_name(3)="O "
day_name(4)="T "
day_name(5)="F "
day_name(6)="L "
day_name(7)="S "

' 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

end select ' end selct of month

%>
<html>
<title>Kalender</title>
<head>
<meta http-equiv="Content-Language" content="da">
</head>

<body>

<p align="center">&nbsp;</p>
<table border="0" width="70%" id="table1" cellspacing="0" align="center">
    <%
    'page header start
    %>
    <tr>
        <td width="57" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
        <td align="center" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;"><b><%=month_name(this_month)%> <%=this_year%> - <%=this_month%>. MÅNED</b></td>
        <td width="42" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
    </tr>
    <%
    'page header end

    '**************************************************
    ' 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
           
              if 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;">&nbsp;</td>
                  <td width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></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;">&nbsp;</td>
                <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
                <%
              else
              %>
                <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%><%=days%></td>
                <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
              <%           
              end if
     
            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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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
                 
        ' increment days
        days = days + 1
       
        if days <= last_day then
               
          %>
          <tr>
          <%             
            if counter = 1 then
           
              if 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;">&nbsp;</td>
                  <td width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></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;">&nbsp;</td>
                <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
                <%
              else
              %>
                <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%><%=days%></td>
                <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
              <%           
              end if
     
            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;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
            <%
            end if
            %>
          </tr>           
          <%     
        end if ' End check for first day of the week
      next
    next
    %>

</table>
</body>
</html>
Avatar billede moejensen Nybegynder
06. juli 2004 - 11:52 #31
FAndt du fejlen?
Avatar billede vbcoder Nybegynder
06. juli 2004 - 12:06 #32
jeps

uge udregningen skulle baseres på mandag som første dag i ugen

og løkken for resten af måneden skulle ændres til at køre 5 uger istedet for fire
Avatar billede moejensen Nybegynder
06. juli 2004 - 12:12 #33
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.
Avatar billede moejensen Nybegynder
09. juli 2004 - 22:07 #34
vbcoder, har du et bud på det sidste problem?
Avatar billede vbcoder Nybegynder
11. juli 2004 - 14:36 #35
den har jeg ikke lige et bud på.
Avatar billede moejensen Nybegynder
27. juli 2004 - 10:28 #36
det var da ærgeligt, ville det være ok at oprette et nyt spørgsmål med henvisning til dette spg, så jeg kan udlode lidt flere point på fejlen?
Avatar billede moejensen Nybegynder
27. juli 2004 - 10:30 #37
jeg havde håbet lidt på at hnteknik, kunne give et bud på fejlen, da han jo har lavet det før.
Avatar billede hnteknik Novice
27. juli 2004 - 11:47 #38
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.
Avatar billede vbcoder Nybegynder
28. juli 2004 - 09:51 #39
--> 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.
Avatar billede moejensen Nybegynder
28. juli 2004 - 09:58 #40
okay, jeg venter bare med spænding :-)
Avatar billede hnteknik Novice
28. juli 2004 - 19:16 #41
Jeg er sikker på, at det er i gode hænder. hvis noget skal oversættes fra jscript til vbscript, så sig til.

PS der manglede et - ikke - i første sætning for oven.
Avatar billede mskjoldp Novice
26. august 2004 - 12:13 #42
:)

er det muligt af få tilgang til den færdige kode som skaber http://www.web4it.dk/kalender/ ?

Jeg er interesseret ifm en løsning til en dyrelæge.

vh Skjold
Avatar billede moejensen Nybegynder
20. september 2004 - 10:05 #43
er der noget nyt om de fermøse uger?
Avatar billede hnteknik Novice
20. september 2004 - 11:17 #44
>>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

Henrik
Avatar billede vbcoder Nybegynder
27. september 2004 - 21:02 #45
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 "

dim day_name(7)
day_name(1)="M "
day_name(2)="T "
day_name(3)="O "
day_name(4)="T "
day_name(5)="F "
day_name(6)="L "
day_name(7)="S "

' 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

end select ' end selct of month

%>
<html>
<title>Kalender</title>
<head>
<meta http-equiv="Content-Language" content="da">
</head>

<body>

<p align="center">&nbsp;</p>
<table border="0" width="70%" id="table1" cellspacing="0" align="center">
    <%
    'page header start
    %>
    <tr>
        <td width="57" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
        <td align="center" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;"><b><%=month_name(this_month)%> <%=this_year%> - <%=this_month%>. MÅNED</b></td>
        <td width="42" style="border-top: solid 2px #000000;border-bottom: solid 2px #000000;">&nbsp;</td>
    </tr>
    <%
    'page header end

    '**************************************************
    ' 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
           
              if DatePart("W", this_year & "-" & this_month & "-" & formatNumber(wdays,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)%><%=wdays%></td>
                  <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
                  <td width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
                <%           
              elseif DatePart("W", this_year & "-" & this_month & "-" & formatNumber(wdays,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)%><%=wdays%></td>
                <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;">&nbsp;</td>
                <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
                <%
              else
              %>
                <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%><%=wdays%></td>
                <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
              <%           
              end if
     
            elseif DatePart("W", this_year & "-" & this_month & "-" & formatNumber(wdays,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)%> <%=wdays%></td>
                <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <%           
           
            elseif DatePart("W", this_year & "-" & this_month & "-" & formatNumber(wdays,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)%> <%=wdays%></td>
              <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <%
           
            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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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
                 
        ' increment wdays
        wdays = wdays + 1
       
        if wdays <= last_day then
               
          %>
          <tr>
          <%             
            if counter = 1 then
           
              if DatePart("W", this_year & "-" & this_month & "-" & formatNumber(wdays,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)%><%=wdays%></td>
                  <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
                  <td width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
                <%           
              elseif DatePart("W", this_year & "-" & this_month & "-" & formatNumber(wdays,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)%><%=wdays%></td>
                <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;">&nbsp;</td>
                <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
                <%
              else
              %>
                <td width="57" style="border-bottom: solid 1px #000000;"><%=day_name(counter)%><%=wdays%></td>
                <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;"><%=start_week%></td>
              <%           
              end if
     
            elseif DatePart("W", this_year & "-" & this_month & "-" & formatNumber(wdays,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)%> <%=wdays%></td>
                <td style="border-bottom: solid 1px #000000;">&nbsp;</td>
                <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <%           
           
            elseif DatePart("W", this_year & "-" & this_month & "-" & formatNumber(wdays,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)%> <%=wdays%></td>
              <td bgcolor="#CCCCCC" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <td bgcolor="#CCCCCC" width="42" style="border-bottom: solid 1px #000000;">&nbsp;</td>
              <%
           
            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;">&nbsp;</td>
              <td width="42" style="border-bottom: solid 1px #000000;">&nbsp;</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%>
Avatar billede vbcoder Nybegynder
27. september 2004 - 21:29 #46
Avatar billede moejensen Nybegynder
28. september 2004 - 08:04 #47
Det ser sku ud til at virke. Du er bare for sej - Endnu engang tusind tak for hjælpen.
Avatar billede vbcoder Nybegynder
28. september 2004 - 19:57 #48
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
     
      start_week = weeknumber(dateserial(this_year,this_month, wdays+1))
     
så bliver ugerne også udskrevet korrekt i januar
Avatar billede moejensen Nybegynder
01. oktober 2004 - 14:55 #49
Et sidste spg.

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?
Avatar billede moejensen Nybegynder
08. oktober 2004 - 14:27 #50
jeg har oprettet et ekstra spg med flere point til dig, da du nu har hjulpet mig en hel del.

http://www.eksperten.dk/spm/548244

Har håver du har et bud på mit sidste spg.
Avatar billede knaseren Nybegynder
11. januar 2006 - 13:03 #51
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
Avatar billede hnteknik Novice
11. januar 2006 - 13:44 #52
Min kalender nu også på http://www.solit4u.dk/kalender/ har ikke disse problemer.
Avatar billede Ny bruger Nybegynder

Din løsning...

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.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

IT-JOB