<% '--- 自分自身のスクリプト名 sPname = Request.ServerVariables("SCRIPT_NAME") iYear = Request("iYear") iMonth= Request("iMonth") If ( iYear="" ) Then dDate = now() '表示したい年月日 iYear = Year(dDate) '表示したい年 iMonth = Month(dDate) '表示したい月 End If w = Weekday( DateSerial(iYear,iMonth,1) ) '今月の始まる曜日(1-7) maxDay = Day( DateSerial(iYear, iMonth+1, 1-1) ) '今月の日数 iDay = 2 - w '初期値の設定(1なら日曜日から表示、0なら月曜日から表示となるように) '(<=0の時は表示させない) '--- 前の月は mDate = DateSerial(iYear,iMonth-1,1) mURL = sPname & "?iYear=" & Year(mDate) & "&iMonth=" & Month(mDate) '--- 次の月は tDate = DateSerial(iYear,iMonth+1,1) tURL = sPname & "?iYear=" & Year(tDate) & "&iMonth=" & Month(tDate) %> <% '--- 曜日名を表示 %><% For x=1 to 7 %><% Next %><% '--- 週を繰り返す For y=1 to 6 '--- 週の中身を繰り返す %><% For x=1 to 7 If ( iDay<=0 ) Then ' 日がきていないので表示しない %><% ElseIf( iDay>maxDay ) Then ' その月の最大日数を越えたので表示しない %><% Else %><% End If iDay = iDay + 1 ' 一日増やす Next %><% Next %>
>← <%=iYear%>年<%=iMonth%>月 >→
<%=WeekDayName(x,True)%>
  <%=iDay%>