2 Replies - 1433 Views - Last Post: 23 May 2009 - 08:12 AM Rate Topic: -----

#1 irishphoenix   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-May 09

DB driven calendar with month nav issues. Can't get db to create a

Post icon  Posted 20 May 2009 - 01:25 PM

I have a dynamic calendar I have been re-writting. (I realize there are lots of free ones online but I needed one to do something else.) this calendar is only a part of the whole.I have everyhting working fine. I have it advancing to the next month and looks really nice. I can't get my query to work. I had it throwing an error, but now it is just spitting out data I didn't want. I will post the code that is the problem, then the whole code for the calendar.


This is the problem code:
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>

 
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>  




this is the whole code for the calendar part:

<!--- Declaration of the variables --->
	   <cfparam name = "month" default = "#DatePart('m', Now())#">
<cfparam name = "year" default = "#DatePart('yyyy', Now())#">
<cfparam name = "currentday" default = "#DatePart('d', Now())#">
<cfparam name = "startmonth" default = "#DatePart('m', Now())#">
<cfparam name = "startyear" default = "#DatePart('yyyy', Now())#">


<!--- Set a requested (or current) month/year date and determine the number of days in the month. --->

<cfset ThisMonthYear = CreateDate(year, month, '1')>
<cfset Days = DaysInMonth(ThisMonthYear)>
<!--- Set the values for the previous and next months for the back/next links.--->
<cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear)>
<cfset LastMonth = DatePart('m', LastMonthYear)>
<cfset LastYear = DatePart('yyyy', LastMonthYear)>
<cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
<cfset NextMonth = DatePart('m', NextMonthYear)>
<cfset NextYear = DatePart('yyyy', NextMonthYear)>


<cfset PreviousDay = DateAdd('d', -1, ThisMonthYear)>
<cfset CurrentYear = DatePart('yyyy', Now())>

	   <table border="0" width="100%" bgcolor ="#ffffff">
			<tr>
				<td align = "center" valign="top">
					<table border="0" width="100%" height="100%">
   <tr>
	  <th align="center" colspan="7" bgcolor="#2b4e6e">
   <cfoutput>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td width="15%" align="left" valign="middle">
  <cfif (LastYear lt CurrentYear) OR (LastYear lte CurrentYear AND LastMonth lt startmonth)> 
<cfelse>
  <a href ="index.cfm?month=#LastMonth#&year=#LastYear#" class="calNav">Prev</a></cfif></td>
		<td width="72%" align="center" valign="middle"><FONT SIZE="3" face="Arial, Helvetica, sans-serif" color="##ffffff">#MonthAsString(month)# #year#</FONT></td>
		<td width="13%" align="right" valign="middle">
  <cfif (NextYear lt CurrentYear) OR (NextYear lte CurrentYear AND NextMonth lt startmonth)> 
<cfelse>
<a href = "index.cfm?month=#NextMonth#&year=#NextYear#" class="calNav">Next</a>  </cfif></td>
	  </tr>
	</table></cfoutput></th>
   </tr>
   <tr>
   
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sun</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Mon</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Tue</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Wed</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Thu</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Fri</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sat</FONT></td>

   </tr>
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>
<cfset ThisDay = 0>
<cfloop condition = "ThisDay LTE Days">
<tr class = "calendar">
							
<cfloop from = "1" to = "7" index = "LoopDay">
<!--- This turns each day into a hyperlink if it is a current or future date --->
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>							   
<cfif ThisDay IS 0>
<cfif DayOfWeek(ThisMonthYear) IS LoopDay>
<cfset ThisDay = 1>
</cfif>
</cfif>
<!---If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay the day of the mnth and increment the value.--->
<cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
<cfoutput>
<!--- I choose to highlight the current day of the year using an IF-ELSE. --->
<cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
<td align = "center" bgcolor="##FFFFCC">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
<cfelse>
<td align = "center">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
</cfif>
</cfoutput>
<cfset ThisDay = ThisDay + 1>
<cfelse>
<td></td>
</cfif>
</cfloop>
</tr>
</cfloop>
</table>
</td>
</tr>
</table> </td>
  </tr>
</table>



Can anyone help me with this? It is the last thing I need to get working and it is driving me crazy. Right now, this code does this:0

0

0

0

1

1

2

2

3

3

and then at the bottom of 32 numbers and doubles of numbers, is the calendar. So my llink code is making it do this.

I realize this is a lot of code. Sorry it is so large. This has been driving me crazy for 3 days now and I can't figure out the problem or how to make it loop through my db records to get the link. Everything else works!


Thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: DB driven calendar with month nav issues. Can't get db to create a

#2 macrem   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-April 09

Re: DB driven calendar with month nav issues. Can't get db to create a

Posted 23 May 2009 - 07:26 AM

View Postirishphoenix, on 20 May, 2009 - 12:25 PM, said:

I have a dynamic calendar I have been re-writting. (I realize there are lots of free ones online but I needed one to do something else.) this calendar is only a part of the whole.I have everyhting working fine. I have it advancing to the next month and looks really nice. I can't get my query to work. I had it throwing an error, but now it is just spitting out data I didn't want. I will post the code that is the problem, then the whole code for the calendar.


This is the problem code:
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>

 
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>  




this is the whole code for the calendar part:

<!--- Declaration of the variables --->
	   <cfparam name = "month" default = "#DatePart('m', Now())#">
<cfparam name = "year" default = "#DatePart('yyyy', Now())#">
<cfparam name = "currentday" default = "#DatePart('d', Now())#">
<cfparam name = "startmonth" default = "#DatePart('m', Now())#">
<cfparam name = "startyear" default = "#DatePart('yyyy', Now())#">


<!--- Set a requested (or current) month/year date and determine the number of days in the month. --->

<cfset ThisMonthYear = CreateDate(year, month, '1')>
<cfset Days = DaysInMonth(ThisMonthYear)>
<!--- Set the values for the previous and next months for the back/next links.--->
<cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear)>
<cfset LastMonth = DatePart('m', LastMonthYear)>
<cfset LastYear = DatePart('yyyy', LastMonthYear)>
<cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
<cfset NextMonth = DatePart('m', NextMonthYear)>
<cfset NextYear = DatePart('yyyy', NextMonthYear)>


<cfset PreviousDay = DateAdd('d', -1, ThisMonthYear)>
<cfset CurrentYear = DatePart('yyyy', Now())>

	   <table border="0" width="100%" bgcolor ="#ffffff">
			<tr>
				<td align = "center" valign="top">
					<table border="0" width="100%" height="100%">
   <tr>
	  <th align="center" colspan="7" bgcolor="#2b4e6e">
   <cfoutput>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td width="15%" align="left" valign="middle">
  <cfif (LastYear lt CurrentYear) OR (LastYear lte CurrentYear AND LastMonth lt startmonth)> 
<cfelse>
  <a href ="index.cfm?month=#LastMonth#&year=#LastYear#" class="calNav">Prev</a></cfif></td>
		<td width="72%" align="center" valign="middle"><FONT SIZE="3" face="Arial, Helvetica, sans-serif" color="##ffffff">#MonthAsString(month)# #year#</FONT></td>
		<td width="13%" align="right" valign="middle">
  <cfif (NextYear lt CurrentYear) OR (NextYear lte CurrentYear AND NextMonth lt startmonth)> 
<cfelse>
<a href = "index.cfm?month=#NextMonth#&year=#NextYear#" class="calNav">Next</a>  </cfif></td>
	  </tr>
	</table></cfoutput></th>
   </tr>
   <tr>
   
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sun</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Mon</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Tue</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Wed</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Thu</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Fri</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sat</FONT></td>

   </tr>
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>
<cfset ThisDay = 0>
<cfloop condition = "ThisDay LTE Days">
<tr class = "calendar">
							
<cfloop from = "1" to = "7" index = "LoopDay">
<!--- This turns each day into a hyperlink if it is a current or future date --->
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>							   
<cfif ThisDay IS 0>
<cfif DayOfWeek(ThisMonthYear) IS LoopDay>
<cfset ThisDay = 1>
</cfif>
</cfif>
<!---If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay the day of the mnth and increment the value.--->
<cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
<cfoutput>
<!--- I choose to highlight the current day of the year using an IF-ELSE. --->
<cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
<td align = "center" bgcolor="##FFFFCC">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
<cfelse>
<td align = "center">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
</cfif>
</cfoutput>
<cfset ThisDay = ThisDay + 1>
<cfelse>
<td></td>
</cfif>
</cfloop>
</tr>
</cfloop>
</table>
</td>
</tr>
</table> </td>
  </tr>
</table>



Can anyone help me with this? It is the last thing I need to get working and it is driving me crazy. Right now, this code does this:0

0

0

0

1

1

2

2

3

3

and then at the bottom of 32 numbers and doubles of numbers, is the calendar. So my llink code is making it do this.

I realize this is a lot of code. Sorry it is so large. This has been driving me crazy for 3 days now and I can't figure out the problem or how to make it loop through my db records to get the link. Everything else works!


Thank you!



try CreateOdbcDate() around your dates
ie #CreateOdbcDate(firstOfTheMonth)#





View Postirishphoenix, on 20 May, 2009 - 12:25 PM, said:

I have a dynamic calendar I have been re-writting. (I realize there are lots of free ones online but I needed one to do something else.) this calendar is only a part of the whole.I have everyhting working fine. I have it advancing to the next month and looks really nice. I can't get my query to work. I had it throwing an error, but now it is just spitting out data I didn't want. I will post the code that is the problem, then the whole code for the calendar.


This is the problem code:
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>

 
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>  




this is the whole code for the calendar part:

<!--- Declaration of the variables --->
	   <cfparam name = "month" default = "#DatePart('m', Now())#">
<cfparam name = "year" default = "#DatePart('yyyy', Now())#">
<cfparam name = "currentday" default = "#DatePart('d', Now())#">
<cfparam name = "startmonth" default = "#DatePart('m', Now())#">
<cfparam name = "startyear" default = "#DatePart('yyyy', Now())#">


<!--- Set a requested (or current) month/year date and determine the number of days in the month. --->

<cfset ThisMonthYear = CreateDate(year, month, '1')>
<cfset Days = DaysInMonth(ThisMonthYear)>
<!--- Set the values for the previous and next months for the back/next links.--->
<cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear)>
<cfset LastMonth = DatePart('m', LastMonthYear)>
<cfset LastYear = DatePart('yyyy', LastMonthYear)>
<cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
<cfset NextMonth = DatePart('m', NextMonthYear)>
<cfset NextYear = DatePart('yyyy', NextMonthYear)>


<cfset PreviousDay = DateAdd('d', -1, ThisMonthYear)>
<cfset CurrentYear = DatePart('yyyy', Now())>

	   <table border="0" width="100%" bgcolor ="#ffffff">
			<tr>
				<td align = "center" valign="top">
					<table border="0" width="100%" height="100%">
   <tr>
	  <th align="center" colspan="7" bgcolor="#2b4e6e">
   <cfoutput>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td width="15%" align="left" valign="middle">
  <cfif (LastYear lt CurrentYear) OR (LastYear lte CurrentYear AND LastMonth lt startmonth)> 
<cfelse>
  <a href ="index.cfm?month=#LastMonth#&year=#LastYear#" class="calNav">Prev</a></cfif></td>
		<td width="72%" align="center" valign="middle"><FONT SIZE="3" face="Arial, Helvetica, sans-serif" color="##ffffff">#MonthAsString(month)# #year#</FONT></td>
		<td width="13%" align="right" valign="middle">
  <cfif (NextYear lt CurrentYear) OR (NextYear lte CurrentYear AND NextMonth lt startmonth)> 
<cfelse>
<a href = "index.cfm?month=#NextMonth#&year=#NextYear#" class="calNav">Next</a>  </cfif></td>
	  </tr>
	</table></cfoutput></th>
   </tr>
   <tr>
   
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sun</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Mon</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Tue</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Wed</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Thu</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Fri</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sat</FONT></td>

   </tr>
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>
<cfset ThisDay = 0>
<cfloop condition = "ThisDay LTE Days">
<tr class = "calendar">
							
<cfloop from = "1" to = "7" index = "LoopDay">
<!--- This turns each day into a hyperlink if it is a current or future date --->
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>							   
<cfif ThisDay IS 0>
<cfif DayOfWeek(ThisMonthYear) IS LoopDay>
<cfset ThisDay = 1>
</cfif>
</cfif>
<!---If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay the day of the mnth and increment the value.--->
<cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
<cfoutput>
<!--- I choose to highlight the current day of the year using an IF-ELSE. --->
<cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
<td align = "center" bgcolor="##FFFFCC">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
<cfelse>
<td align = "center">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
</cfif>
</cfoutput>
<cfset ThisDay = ThisDay + 1>
<cfelse>
<td></td>
</cfif>
</cfloop>
</tr>
</cfloop>
</table>
</td>
</tr>
</table> </td>
  </tr>
</table>



Can anyone help me with this? It is the last thing I need to get working and it is driving me crazy. Right now, this code does this:0

0

0

0

1

1

2

2

3

3

and then at the bottom of 32 numbers and doubles of numbers, is the calendar. So my llink code is making it do this.

I realize this is a lot of code. Sorry it is so large. This has been driving me crazy for 3 days now and I can't figure out the problem or how to make it loop through my db records to get the link. Everything else works!


Thank you!

Was This Post Helpful? 0
  • +
  • -

#3 irishphoenix   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-May 09

Re: DB driven calendar with month nav issues. Can't get db to create a

Posted 23 May 2009 - 08:12 AM

View Postmacrem, on 23 May, 2009 - 06:26 AM, said:

View Postirishphoenix, on 20 May, 2009 - 12:25 PM, said:

I have a dynamic calendar I have been re-writting. (I realize there are lots of free ones online but I needed one to do something else.) this calendar is only a part of the whole.I have everyhting working fine. I have it advancing to the next month and looks really nice. I can't get my query to work. I had it throwing an error, but now it is just spitting out data I didn't want. I will post the code that is the problem, then the whole code for the calendar.


This is the problem code:
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>

 
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>  




this is the whole code for the calendar part:

<!--- Declaration of the variables --->
	   <cfparam name = "month" default = "#DatePart('m', Now())#">
<cfparam name = "year" default = "#DatePart('yyyy', Now())#">
<cfparam name = "currentday" default = "#DatePart('d', Now())#">
<cfparam name = "startmonth" default = "#DatePart('m', Now())#">
<cfparam name = "startyear" default = "#DatePart('yyyy', Now())#">


<!--- Set a requested (or current) month/year date and determine the number of days in the month. --->

<cfset ThisMonthYear = CreateDate(year, month, '1')>
<cfset Days = DaysInMonth(ThisMonthYear)>
<!--- Set the values for the previous and next months for the back/next links.--->
<cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear)>
<cfset LastMonth = DatePart('m', LastMonthYear)>
<cfset LastYear = DatePart('yyyy', LastMonthYear)>
<cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
<cfset NextMonth = DatePart('m', NextMonthYear)>
<cfset NextYear = DatePart('yyyy', NextMonthYear)>


<cfset PreviousDay = DateAdd('d', -1, ThisMonthYear)>
<cfset CurrentYear = DatePart('yyyy', Now())>

	   <table border="0" width="100%" bgcolor ="#ffffff">
			<tr>
				<td align = "center" valign="top">
					<table border="0" width="100%" height="100%">
   <tr>
	  <th align="center" colspan="7" bgcolor="#2b4e6e">
   <cfoutput>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td width="15%" align="left" valign="middle">
  <cfif (LastYear lt CurrentYear) OR (LastYear lte CurrentYear AND LastMonth lt startmonth)> 
<cfelse>
  <a href ="index.cfm?month=#LastMonth#&year=#LastYear#" class="calNav">Prev</a></cfif></td>
		<td width="72%" align="center" valign="middle"><FONT SIZE="3" face="Arial, Helvetica, sans-serif" color="##ffffff">#MonthAsString(month)# #year#</FONT></td>
		<td width="13%" align="right" valign="middle">
  <cfif (NextYear lt CurrentYear) OR (NextYear lte CurrentYear AND NextMonth lt startmonth)> 
<cfelse>
<a href = "index.cfm?month=#NextMonth#&year=#NextYear#" class="calNav">Next</a>  </cfif></td>
	  </tr>
	</table></cfoutput></th>
   </tr>
   <tr>
   
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sun</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Mon</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Tue</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Wed</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Thu</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Fri</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sat</FONT></td>

   </tr>
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>
<cfset ThisDay = 0>
<cfloop condition = "ThisDay LTE Days">
<tr class = "calendar">
							
<cfloop from = "1" to = "7" index = "LoopDay">
<!--- This turns each day into a hyperlink if it is a current or future date --->
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>							   
<cfif ThisDay IS 0>
<cfif DayOfWeek(ThisMonthYear) IS LoopDay>
<cfset ThisDay = 1>
</cfif>
</cfif>
<!---If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay the day of the mnth and increment the value.--->
<cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
<cfoutput>
<!--- I choose to highlight the current day of the year using an IF-ELSE. --->
<cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
<td align = "center" bgcolor="##FFFFCC">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
<cfelse>
<td align = "center">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
</cfif>
</cfoutput>
<cfset ThisDay = ThisDay + 1>
<cfelse>
<td></td>
</cfif>
</cfloop>
</tr>
</cfloop>
</table>
</td>
</tr>
</table> </td>
  </tr>
</table>



Can anyone help me with this? It is the last thing I need to get working and it is driving me crazy. Right now, this code does this:0

0

0

0

1

1

2

2

3

3

and then at the bottom of 32 numbers and doubles of numbers, is the calendar. So my llink code is making it do this.

I realize this is a lot of code. Sorry it is so large. This has been driving me crazy for 3 days now and I can't figure out the problem or how to make it loop through my db records to get the link. Everything else works!


Thank you!



try CreateOdbcDate() around your dates
ie #CreateOdbcDate(firstOfTheMonth)#





View Postirishphoenix, on 20 May, 2009 - 12:25 PM, said:

I have a dynamic calendar I have been re-writting. (I realize there are lots of free ones online but I needed one to do something else.) this calendar is only a part of the whole.I have everyhting working fine. I have it advancing to the next month and looks really nice. I can't get my query to work. I had it throwing an error, but now it is just spitting out data I didn't want. I will post the code that is the problem, then the whole code for the calendar.


This is the problem code:
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>

 
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>  




this is the whole code for the calendar part:

<!--- Declaration of the variables --->
	   <cfparam name = "month" default = "#DatePart('m', Now())#">
<cfparam name = "year" default = "#DatePart('yyyy', Now())#">
<cfparam name = "currentday" default = "#DatePart('d', Now())#">
<cfparam name = "startmonth" default = "#DatePart('m', Now())#">
<cfparam name = "startyear" default = "#DatePart('yyyy', Now())#">


<!--- Set a requested (or current) month/year date and determine the number of days in the month. --->

<cfset ThisMonthYear = CreateDate(year, month, '1')>
<cfset Days = DaysInMonth(ThisMonthYear)>
<!--- Set the values for the previous and next months for the back/next links.--->
<cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear)>
<cfset LastMonth = DatePart('m', LastMonthYear)>
<cfset LastYear = DatePart('yyyy', LastMonthYear)>
<cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
<cfset NextMonth = DatePart('m', NextMonthYear)>
<cfset NextYear = DatePart('yyyy', NextMonthYear)>


<cfset PreviousDay = DateAdd('d', -1, ThisMonthYear)>
<cfset CurrentYear = DatePart('yyyy', Now())>

	   <table border="0" width="100%" bgcolor ="#ffffff">
			<tr>
				<td align = "center" valign="top">
					<table border="0" width="100%" height="100%">
   <tr>
	  <th align="center" colspan="7" bgcolor="#2b4e6e">
   <cfoutput>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td width="15%" align="left" valign="middle">
  <cfif (LastYear lt CurrentYear) OR (LastYear lte CurrentYear AND LastMonth lt startmonth)> 
<cfelse>
  <a href ="index.cfm?month=#LastMonth#&year=#LastYear#" class="calNav">Prev</a></cfif></td>
		<td width="72%" align="center" valign="middle"><FONT SIZE="3" face="Arial, Helvetica, sans-serif" color="##ffffff">#MonthAsString(month)# #year#</FONT></td>
		<td width="13%" align="right" valign="middle">
  <cfif (NextYear lt CurrentYear) OR (NextYear lte CurrentYear AND NextMonth lt startmonth)> 
<cfelse>
<a href = "index.cfm?month=#NextMonth#&year=#NextYear#" class="calNav">Next</a>  </cfif></td>
	  </tr>
	</table></cfoutput></th>
   </tr>
   <tr>
   
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sun</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Mon</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Tue</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Wed</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Thu</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Fri</FONT></td>
	<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sat</FONT></td>

   </tr>
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>
<cfset ThisDay = 0>
<cfloop condition = "ThisDay LTE Days">
<tr class = "calendar">
							
<cfloop from = "1" to = "7" index = "LoopDay">
<!--- This turns each day into a hyperlink if it is a current or future date --->
<cfoutput>
<cfif thisday is day(now())>
		<b>#ThisDay#</b>
	<cfelse>
		<cfif listFind(days,thisday)>
			<a href="##"><b>thisday</b></a>
		<cfelse>
			#thisday#
		</cfif>
	</cfif>
</cfoutput>							   
<cfif ThisDay IS 0>
<cfif DayOfWeek(ThisMonthYear) IS LoopDay>
<cfset ThisDay = 1>
</cfif>
</cfif>
<!---If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay the day of the mnth and increment the value.--->
<cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
<cfoutput>
<!--- I choose to highlight the current day of the year using an IF-ELSE. --->
<cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
<td align = "center" bgcolor="##FFFFCC">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
<cfelse>
<td align = "center">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
</cfif>
</cfoutput>
<cfset ThisDay = ThisDay + 1>
<cfelse>
<td></td>
</cfif>
</cfloop>
</tr>
</cfloop>
</table>
</td>
</tr>
</table> </td>
  </tr>
</table>



Can anyone help me with this? It is the last thing I need to get working and it is driving me crazy. Right now, this code does this:0

0

0

0

1

1

2

2

3

3

and then at the bottom of 32 numbers and doubles of numbers, is the calendar. So my llink code is making it do this.

I realize this is a lot of code. Sorry it is so large. This has been driving me crazy for 3 days now and I can't figure out the problem or how to make it loop through my db records to get the link. Everything else works!


Thank you!


I have that in my query now. But I am not getting my link, no errors anymore, but the link isn't appearing with my if statement. this is what I changed things to with my query and if statement:

<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID 
FROM events 
WHERE eventDate = #CreateODBCDate("07/12/2005")#
</cfquery>

<cfset ThisMonthYear = CreateDate(year, month, '1')>
<cfset Days = DaysInMonth(ThisMonthYear)>
<cfif #PreviousDay# EQ Now() - 1>
<cfoutput query="CaleventRec">
<a href = "detail.cfm?ID=#ID#">#Days#</a>
</cfoutput>
</cfif>



I tried a number of different if statements, like
<cfif days EQ #eventdate#>


and none of these work. Should I be compairing the actualy date with my db date in my where statement? or is there a way to get this if statement to work? this is the final hurdle. thank you for the help
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1