#1
  1. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Oct 2005
    Posts
    82
    Rep Power
    14

    Exclamation Problem with a calendar.


    Hello. Long time i've not been here but its okay.

    I've downloaded a calendar ASP Script. I would like to know, how can i change the date order to "day of the week, day/month/year"...I'm so newbie to asp(more than i was, as i wasn't working with asp,i was working with hardware),and i need to change this date format.

    There's the script...first the calendar script.

    Code:
    <!-- #include file ="dsn.asp" -->
    <!-- #include file="adovbs.inc" -->
    <%
    	Function GetLastDay(intMonthNum, intYearNum)
    		Dim dNextStart
    		If CInt(intMonthNum) = 12 Then
    			dNextStart = CDate( "1/1/" & intYearNum)
    		Else
    			dNextStart = CDate(intMonthNum + 1 & "/1/" & intYearNum)
    		End If
    		GetLastDay = Day(dNextStart - 1)
    	End Function
    	
    	Sub Write_TD(sValue, sClass)
    		Response.Write "		<TD ALIGN='RIGHT' WIDTH=20 HEIGHT=15 VALIGN='BOTTOM' CLASS='" & sClass & "'> " & sValue & "</TD>" & vbCrLf
    	End Sub
    
    
    	' Constants for the days of the week
    	Const cSUN = 1, cMON = 2, cTUE = 3, cWED = 4, cTHU = 5, cFRI = 6, cSAT = 7
    	
    	' Get the name of this file
    	sScript = Request.ServerVariables("SCRIPT_NAME")
    	
    	' Check for valid month input
    	If IsEmpty(Request("MONTH")) OR NOT IsNumeric(Request("MONTH")) Then
    	  datToday = Date()
    	  intThisMonth = Month(datToday)
    	ElseIf CInt(Request("MONTH")) < 1 OR CInt(Request("MONTH")) > 12 Then
    	  datToday = Date()
    	  intThisMonth = Month(datToday)
    	Else
    	  intThisMonth = CInt(Request("MONTH"))
    	End If
    	
    	' Check for valid year input
    	If IsEmpty(Request("YEAR")) OR NOT IsNumeric(Request("YEAR")) Then
    	  datToday = Date()
    	  intThisYear = Year(datToday)
    	Else
    	  intThisYear = CInt(Request("YEAR"))
    	End If
    
    	strMonthName = MonthName(intThisMonth)
    	datFirstDay = DateSerial(intThisYear, intThisMonth, 1)
    	intFirstWeekDay = WeekDay(datFirstDay, vbSunday)
    	intLastDay = GetLastDay(intThisMonth, intThisYear)
    	
    	' Get the previous month and year
    	intPrevMonth = intThisMonth - 1
    	If intPrevMonth = 0 Then
    		intPrevMonth = 12
    		intPrevYear = intThisYear - 1
    	Else
    		intPrevYear = intThisYear	
    	End If
    	
    	' Get the next month and year
    	intNextMonth = intThisMonth + 1
    	If intNextMonth > 12 Then
    		intNextMonth = 1
    		intNextYear = intThisYear + 1
    	Else
    		intNextYear = intThisYear
    	End If
    
    	' Get the last day of previous month. Using this, find the sunday of
    	' last week of last month
    	LastMonthDate = GetLastDay(intLastMonth, intPrevYear) - intFirstWeekDay + 2
    	NextMonthDate = 1
    
    	' Initialize the print day to 1  
    	intPrintDay = 1
    
    	' Open a record set of schedules
    	Set Rs = Server.CreateObject("ADODB.RecordSet")
    	
    	' These dates are used in the SQL
    	dFirstDay = intThisMonth & "/1/" & intThisYear
    	dLastDay 	= intThisMonth & "/" & intLastDay & "/" & intThisYear
    
    	sSQL = 	"SELECT DISTINCT Start_Date, End_Date FROM tEvents WHERE " & _
    					"(Start_Date >=#" & dFirstDay & "# AND Start_Date <= #" & dLastDay & "#) " & _
    					"OR " & _
    					"(End_Date >=#" & dFirstDay & "# AND End_Date <= #" & dLastDay & "#) " & _
    					"OR " & _
    					"(Start_Date < #" & dFirstDay & "# AND End_Date > #" & dLastDay & "# )"  & _
    					"ORDER BY Start_Date"
    	'Response.Write sSQL
    
    	' Open the RecordSet with a static cursor. This cursor provides bi-directional navigation
    	Rs.Open sSQL, sDSN, adOpenStatic, adLockReadOnly, adCmdText
    %>
    
    <html>
    <head>
    <meta HTTP-EQUIV="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Schedule for <% = strMonthName & " " & intThisYear %></title>
    <style TYPE="text/css">
      TD.NON {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#C0C0C0; font-weight :normal;}
      TD.TOP {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#0000FF; font-weight :bold;}
      TD.Some {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :normal;}
    
      A.NOEVENT:Link {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :normal; text-decoration: none;}
      A.NOEVENT:Visited {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :normal; text-decoration: none;}
    
      A.EVENT:Link {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :bold; text-decoration: none;}
      A.EVENT:Visited {font-family :Tahoma, Verdana, Arial; font-size :12px; color :#000000; font-weight :bold; text-decoration: none;}
    
      A.NORMAL:Link {font-family :Verdana, Arial; font-size :12px; color :#0000FF; font-weight :normal; text-decoration: none;}
      A.NORMAL:Visited {font-family :Verdana, Arial; font-size :12px; color :#0000FF; font-weight :normal; text-decoration: none;}
    </style>
    </head>
    <body BGCOLOR="#CCCCFF" TEXT="#0000FF" LEFTMARGIN="3" LINK="#000000" VLINK="#000000">
    <br>
    
    <table ALIGN="CENTER" BORDER="1" CELLSPACING="0" CELLPADDING="2" BGCOLOR="White" BORDERCOLOR="Gray">
    <tr><td>
    	<table WIDTH="140" BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#FFFFFF">
    		<tr HEIGHT="18" BGCOLOR="Silver">
    			<td WIDTH="20" HEIGHT="18" ALIGN="LEFT" VALIGN="MIDDLE"><a HREF="<% =sScript%>?month=<% =IntPrevMonth %>&amp;year=<% =IntPrevYear %>"><img SRC="images/prev.gif" WIDTH="10" HEIGHT="18" BORDER="0" ALT="Previous Month"></a></td>
    			<td WIDTH="120" COLSPAN="5" ALIGN="CENTER" VALIGN="MIDDLE" CLASS="SOME"><% = strMonthName & " " & intThisYear %></td>
    			<td WIDTH="20" HEIGHT="18" ALIGN="RIGHT" VALIGN="MIDDLE"><a HREF="<% =sScript %>?month=<% =IntNextMonth %>&amp;year=<% =IntNextYear %>"><img SRC="images/next.gif" WIDTH="10" HEIGHT="18" BORDER="0" ALT="Next Month"></a></td>
    		</tr>
    	  <tr>
    			<td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">S</td>
    			<td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">M</td>
    			<td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">T</td>
    			<td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">W</td>
    			<td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">T</td>
    			<td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">F</td>
    			<td ALIGN="RIGHT" CLASS="SOME" WIDTH="20" HEIGHT="15" VALIGN="BOTTOM">S</td>
    	  </tr>
    	  <tr><td HEIGHT="1" ALIGN="MIDDLE" COLSPAN="7"><img SRC="images/line.gif" HEIGHT="1" WIDTH="140" BORDER="0"></td></tr>
    	  <%
    			' Initialize the end of rows flag to false
    			EndRows = False
    			Response.Write vbCrLf
    			
    			' Loop until all the rows are exhausted
    		 	Do While EndRows = False
    				' Start a table row
    				Response.Write "	<TR>" & vbCrLf
    				' This is the loop for the days in the week
    				For intLoopDay = cSUN To cSAT
    					' If the first day is not sunday then print the last days of previous month in grayed font
    					If intFirstWeekDay > cSUN Then
    						Write_TD LastMonthDate, "NON"
    						LastMonthDate = LastMonthDate + 1
    						intFirstWeekDay = intFirstWeekDay - 1
    					' The month starts on a sunday	
    					Else
    						' If the dates for the month are exhausted, start printing next month's dates
    						' in grayed font
    						If intPrintDay > intLastDay Then
    							Write_TD NextMonthDate, "NON"
    							NextMonthDate = NextMonthDate + 1
    							EndRows = True 
    						Else
    							' If last day of the month, flag the end of the row
    							If intPrintDay = intLastDay Then
    								EndRows = True
    							End If
    							
    							dToday = CDate(intThisMonth & "/" & intPrintDay & "/" & intThisYear)  
    							If NOT Rs.EOF Then
    								' Set events flag to false. This means the day has no event in it
    								bEvents = False
    							  Do While NOT Rs.EOF AND bEvents = False
    									' If the date falls within the range of dates in the recordset, then 
    									' the day has an event. Make the events flag True
    							    If dToday >= Rs("Start_Date") AND dToday <= Rs("End_Date") Then
    										' Print the date in a highlighted font
    							      Write_TD "<A HREF=events.asp?date="& Server.URLEncode(dToday) & " CLASS='EVENT' TARGET='rightframe'> " & intPrintDay & "</A>", "HL"
    										bEvents = True
    									' If the Start date is greater than the date itself, there is no point
    									' checking other records. Exit the loop	
    							    ElseIf dToday < Rs("Start_Date") Then
    										Exit Do
    									' Move to the next record
    									Else	
    								    Rs.MoveNext
    									End If
    							  Loop
    								' Checks for that day
    								Rs.MoveFirst
    							End If
    							
    							' If the event flag is not raise for that day, print it in a plain font
    							If bEvents = False Then
    								Write_TD "<A HREF=events.asp?date="& Server.URLEncode(dToday) & " CLASS='NOEVENT' TARGET='rightframe'> " & intPrintDay & "</A>", "SOME"
    							End If
    						End If 
    						
    						' Increment the date. Done once in the loop.
    						intPrintDay = intPrintDay + 1
    					End If
    				
    				' Move to the next day in the week
    				Next
    				Response.Write "	</TR>" & vbCrLf
    				
    			Loop 
    			Rs.Close
    			Set Rs = Nothing
    		%>
    	</table>
    	</td></tr>
    </table>
    
    </body>
    </html>
    the second part of this thread i will post as a "reply"
  2. #2
  3. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Oct 2005
    Posts
    82
    Rep Power
    14
    Then,you click in a day and get on this page:
    Code:
    <!--#include file="adovbs.inc"-->
    <!--#include file="dsn.asp"-->
    <%
    	If IsEmpty(Request.QueryString("Date")) OR NOT IsDate(Request.QueryString("Date")) Then
    		dDate = Date
    	Else
    		dDate = CDate(Request.QueryString("Date"))
    	End If
    %>	
    <HTML>
    <HEAD>
    <TITLE>Eventos em <%= FormatDateTime(dDate, 1) %></TITLE>
    </HEAD>
    <BODY BACKGROUND="images/image3.gif" LEFTMARGIN="5">
    <P>&nbsp;</P>
    <P ALIGN=RIGHT><IMG SRC="images/events.gif" WIDTH=400 HEIGHT=50 BORDER=0 ALT=""></P>
    <BR CLEAR=ALL>
    
    <%
      ' Open a record set of schedules
    	Response.Write "<FONT COLOR='Gray' FACE='Tahoma, Verdana' SIZE=2>" & FormatDateTime(dDate, 1) & "</FONT><BR><BR>" & vbCrLf
      Set Rs = Server.CreateObject("ADODB.RecordSet")
    	sSQL = 	"SELECT * FROM tEvents " & _
    					"WHERE Start_Date <= #" & dDate & "# AND End_Date >= #" & dDate & "# ORDER BY Event_ID "
    
      Rs.Open sSQL, sDSN, adOpenStatic, adLockReadOnly, adCmdText
    	If NOT Rs.EOF Then
    		arrColor =Array("#000000", "#CC9966", "#336600", "#003366", "#FFCC66", "#0000FF", "#FF0000")
    		iIndex = 0
    		
    		Do While NOT Rs.EOF
    			' Create the outer table
    			Response.Write "<TABLE WIDTH='400' BORDER='0' CELLSPACING='0' CELLPADDING='1' BGCOLOR='" & arrColor(iIndex) & "'><TR><TD>" & vbCrLf
    			' Create the inner table
    			Response.Write "<TABLE WIDTH='100%' CELLSPACING=0 BORDER=0 CELLPADDING=2 BGCOLOR='White'>" & vbCrLf
    			Response.Write "<TR BGCOLOR='" & arrColor(iIndex) & "'><TD HEIGHT=20 WIDTH=220 VALIGN='top'><B><FONT FACE='Verdana, Tahoma' SIZE='1' COLOR='White'>" & vbCrLf
    			Response.Write Trim(Rs("Event_Title")) & VbCrLf
    			Response.Write "</FONT></B>&nbsp;</TD>" & vbCrLf
    			If Session("Admin") = 1 Then
    				Response.Write "<TD WIDTH=90 HEIGHT=20 VALIGN='MIDDLE'><A HREF='addedit.asp?Event_ID=" & Rs("Event_ID") & "'><IMG SRC='images/edit.gif' BORDER=0 HEIGHT=20 WIDTH=90></A></TD>" & vbCrLf
    				Response.Write "<TD WIDTH=90 HEIGHT=20 VALIGN='MIDDLE'><A HREF='delete.asp?date=" & Server.URLEncode(dDate) & "&Event_ID=" & Rs("Event_ID") & "'><IMG SRC='images/delete.gif' BORDER=0 HEIGHT=20 WIDTH=90></A></TD>" & vbCrLf
    			End If
    			Response.Write "</TR>" & vbCrLf
    			
    			Response.Write "<TR><TD VALIGN='top' COLSPAN='3'>" & vbCrLf
    			
    			' If the event lasts more than one day, indidate the start and end dates
    			If Rs("Start_Date") <> Rs("End_Date") Then
    				Response.Write "<FONT FACE='Verdana, Arial' SIZE=1 COLOR='Gray'>Starts: " & Rs("Start_Date") & vbCrLf
    				Response.Write "<BR>Ends: " & Rs("End_Date") & vbCrLf
    				Response.Write "</FONT><P>"
    			End If
    			
    			' Print the event details
    			Response.Write "<FONT FACE='Verdana, Tahoma' SIZE='1' COLOR='Black'>" & vbCrLf
    			Response.Write Replace(Rs("Event_Details") & " ", vbCrLf, "<BR>") & vbCrLf
    			Response.Write "</FONT></TD></TR>" & vbCrLf
    			Response.Write "</TABLE></TD></TR></TABLE>" & vbCrLf
    			
    			Response.Write "<BR>" & vbCrLf
    			Rs.MoveNext
    			iIndex = iIndex + 1
    			If iIndex = 3 Then
    				iIndex = 0
    			End If
    		Loop
    	End If	
    %>
    
    	
    
    
    
    <!-- #include file="menu.inc" -->
    </BODY>
    </HTML>
    I hope that someone can help.
    Thanks
    Pablo.

Similar Threads

  1. working with a MS Access calendar
    By lil_me in forum Microsoft Access Help
    Replies: 2
    Last Post: January 22nd, 2010, 07:56 PM
  2. Problem with code on OCX Calendar
    By AdamsKelly in forum Microsoft Access Help
    Replies: 1
    Last Post: September 16th, 2005, 07:19 AM
  3. ASP view of Outlook Public Folder calendar
    By NBCymru in forum ASP Development
    Replies: 2
    Last Post: September 2nd, 2005, 10:32 AM
  4. full year calendar with multi-selection dates.
    By rainbow11 in forum .NET Development
    Replies: 1
    Last Post: December 29th, 2004, 12:27 PM
  5. I am blank !!! Calendar
    By tonya in forum ASP Development
    Replies: 10
    Last Post: April 3rd, 2003, 03:07 PM

IMN logo majestic logo threadwatch logo seochat tools logo