Need To Return Calendar Events For Current Day
Hello,
I have a calendar which includes seperate start and end date fields. I need to write a query that will return events for each day in a month, but I need to be mindful of the fact that some events span multiple days. Here is my query so far which isn't working quite right.
<cfquery name="qTodayEvents" datasource="#getDatasource()#">
SELECT eventID, title, summary, code, description
FROM events INNER JOIN eventTypes ON events.typeID=eventTypes.typeID
WHERE deleted=0
AND
(
startDate >= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayStartTime#" />
AND startDate <= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayEndTime#" />
) OR (
endDate >= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayStartTime#" />
AND endDate <= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayEndTime#" />
) OR (
startDate <= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayStartTime#" />
AND endDate >= <cfqueryparam cfsqltype="cf_sql_timestamp" value="#todayEndTime#" />
)
</cfquery>
The query is located inside a loop which loops through the days in a given month.
Does anyone know what I am doing wrong? Any assistance would be appreciated.
Many thanks,
Simon
