School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,406 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,586 people online right now. Registration is fast and FREE... Join Now!




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

 

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

irishphoenix

20 May, 2009 - 12:25 PM
Post #1

New D.I.C Head
*

Joined: 20 May, 2009
Posts: 4

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

CODE

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



User is offlineProfile CardPM
+Quote Post


macrem

RE: DB Driven Calendar With Month Nav Issues. Can't Get Db To Create A

23 May, 2009 - 06:26 AM
Post #2

New D.I.C Head
*

Joined: 6 Apr, 2009
Posts: 2

QUOTE(irishphoenix @ 20 May, 2009 - 12: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:
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:

CODE

<!--- 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)#





QUOTE(irishphoenix @ 20 May, 2009 - 12: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:
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:

CODE

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


User is offlineProfile CardPM
+Quote Post

irishphoenix

RE: DB Driven Calendar With Month Nav Issues. Can't Get Db To Create A

23 May, 2009 - 07:12 AM
Post #3

New D.I.C Head
*

Joined: 20 May, 2009
Posts: 4

QUOTE(macrem @ 23 May, 2009 - 06:26 AM) *

QUOTE(irishphoenix @ 20 May, 2009 - 12: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:
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:

CODE

<!--- 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)#





QUOTE(irishphoenix @ 20 May, 2009 - 12: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:
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:

CODE

<!--- 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:

CODE

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

<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
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 11:05PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month