Hey thanks,
It displays the current month but I can get it to do previous and next.... can you check out my code...
I have changed it slightly...
It's uploaded at
Cheers
Mark ;-)
<!--- Inputs required: DisplayDate (ODBC Date/Time object) --->
<CFSET TodaysDate = Now()>
<CFSET ThisMonth = Month(TodaysDate)>
<CFSET ThisDay = Day(TodaysDate)>
<CFSET DisplayDate = Now()>
<CFSET PageLink = "cal.cfm">
<CFOUTPUT>
<TABLE WIDTH="200" CELLPADDING="3" BORDER="1">
<TR BGCOLOR="##ff9900">
<TD COLSPAN="7" ALIGN="center">
<B>#MonthAsString(Month(DisplayDate))# #Year(DisplayDate)#</B>
</TD>
</TR>
</CFOUTPUT>
<!--- Now we need to display the weeks of the month. --->
<!--- The logic here is not too complex. We know that every 7 days we need to start a new table row. The only hard part is figuring out how much we need to pad the first and last row. To figure out how much we need to pad, we just figure out what day of the week the first of the month is. if it is wednesday, then we need to pad for sunday,monday, and tuesday. 3 days. --->
<TR>
<CFSET FIRSTOFMONTH=CreateDate(Year(DisplayDate),Month(DisplayDate),1)>
<CFSET TOPAD=DayOfWeek(FIRSTOFMONTH) - 1>
<CFSET PADSTR=RepeatString("<TD> </TD>",TOPAD)>
<CFOUTPUT>#PADSTR#</CFOUTPUT>
<CFSET DW=TOPAD>
<CFLOOP INDEX="X" FROM="1" TO="#DaysInMonth(DisplayDate)#">
<TD ALIGN="center"><CFOUTPUT><A HREF="#PageLink#?gigid=#X#">#X#</A></CFOUTPUT></TD>
<CFSET DW=DW + 1>
<CFIF DW EQ 7>
</TR>
<CFSET DW=0>
<CFIF X LT DaysInMonth(DisplayDate)><TR></CFIF>
</CFIF>
</CFLOOP>
<!---
Now we need to do a pad at the end, just to make our table "proper" we can figure out how much the pad should be by examining DW --->
<CFSET TOPAD=7 - DW>
<CFIF TOPAD LT 7>
<CFSET PADSTR=RepeatString("<TD> </TD>",TOPAD)>
<CFOUTPUT>#PADSTR#</CFOUTPUT>
</CFIF>
</TR>
</TABLE>
<!--- This is the navigation bar. --->
<CFOUTPUT>
<!--- Calculate dates to pass back to ViewSchedule.cfm --->
<CFSET PriorDay = 1>
<CFSET PriorMonth = Month(DateAdd("m",-1,DisplayDate))>
<CFIF PriorMonth EQ ThisMonth>
<CFSET PriorDay = ThisDay>
</CFIF>
<CFIF PriorMonth EQ 12>
<CFSET PriorYear = Year(DateAdd("yyyy",-1,DisplayDate))>
<CFELSE>
<CFSET PriorYear = Year(DisplayDate)>
</CFIF>
<CFSET PriorDate = CreateDate(PriorYear,PriorMonth,PriorDay)>
<CFSET NextDay = 1>
<CFSET NextMonth = Month(DateAdd("m",1,DisplayDate))>
<CFIF NextMonth EQ ThisMonth>
<CFSET NextDay = ThisDay>
</CFIF>
<CFIF NextMonth EQ 1>
<CFSET NextYear = Year(DateAdd("yyyy",1,DisplayDate))>
<CFELSE>
<CFSET NextYear = Year(DisplayDate)>
</CFIF>
<CFSET NextDate = CreateDate(NextYear,NextMonth,NextDay)>
<!--- Display the navigation bar. --->
<TABLE WIDTH="200" BORDER="1">
<TR>
<TD ALIGN="center"><A HREF="cal.cfm?DisplayDate=#PriorDate#"><<< 1Prior</A></TD>
<TD ALIGN="center"><A HREF="cal.cfm?DisplayDate=#NextDate#">Next2 >>></A></TD>
</TR>
</TABLE>
</CFOUTPUT>