Query WHERE statement to compare db record date
Hello
I can't get this where statement to work. I have it now so it is not throwing any errors, but it also isn't doing what it is supposed to.
I am trying to match records date in my table with the actual calendar date, if there is a match, my cfif will take that match, and make it a link in the proper date. (it is a small calendar with the month, and the days of week with dates, each date will be normal, accept if there is a record for that date, it makes a link.
This is my code, like I said, It doesn't throw an error, but it is not working either.
My Query:
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID
FROM events
WHERE eventDate >= #CreateODBCDate("07/12/2005")# AND eventDate = #Days#
</cfquery>
This is the cfif statement:
<cfoutput query="CaleventRec">
<cfif Days EQ '#eventdate#'>
<a href = "detail.cfm?id=#ID#">#Days#</a>
</cfif>
</cfoutput>
this is all the code together:
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID
FROM events
WHERE eventDate >= #CreateODBCDate("07/12/2005")# AND eventDate = #Days#
</cfquery>
<!--- Set the ThisDay variable to 0. This value will remain 0 until the day of the week on which the first day of the month falls on is reached. --->
<cfset ThisDay = 0>
<!--- Loop through until the number of days in the month is reached. --->
<cfloop condition = "ThisDay LTE Days">
<tr>
<!--- Loop though each day of the week. --->
<cfloop from = "1" to = "7" index = "LoopDay">
<!--- This turns each day into a hyperlink if it is a current or future date --->
<cfoutput query="CaleventRec">
<cfif Days EQ '#eventdate#'>
<a href = "detail.cfm?id=#ID#">#Days#</a>
</cfif>
</cfoutput>
<!---
If ThisDay is still 0, check to see if the current day of the week in the loop matches the day of the week for the first day of the month.
If the values match, set ThisDay to 1.
Otherwise, the value will remain 0 until the correct day of the week is found.
--->
<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="##FFFF99">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font class = "calendartoday">#ThisDay#</font>
</td>
<cfelse>
<td align = "center">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font class = "calendar">#ThisDay#</font>
</td>
</cfif>
</cfoutput>
<cfset ThisDay = ThisDay + 1>
<cfelse>
<td></td>
</cfif>
</cfloop>
</tr>
</cfloop>
I know my where statement is incorrect, I am also not sure if my cfif statement is correct either. Can anyone help me figure this out?
thank you!
CFmonger
