I have the following code for items that get placed on an Upcoming Events page:
<cfquery name="eventList" datasource="Functions">
SELECT TOP 3 EventDate,Title, OneLineDesc, Description, EventTime,
EventTimeTo, SubCategory, Name
FROM Events5051, EventsSubCategories5051
WHERE Events5051.SubCategoryID=EventsSubCategories5051.SubCategoryID
AND EventDate>= #CreateODBCDate(now())#
ORDER BY EventDate, EventTime ASC
</cfquery>
<cfoutput query="eventList">
<cfquery name="getStartTime" datasource="Functions">
SELECT *
FROM DateTimeFormat
WHERE TimeValue='#eventList.EventTime#'
</cfquery>
<cfquery name="getEndTime" datasource="Functions">
SELECT *
FROM DateTimeFormat
WHERE TimeValue='#eventList.EventTimeTo#'
</cfquery>
<cfset varTimeStart = #getStartTime.TimeDisplay#>
<cfset varTimeStop = #getEndTime.TimeDisplay#>
#varTimeStart# - #varTimeStop#<br >
#eventList.Description#</p>
<p class="style2">#eventList.OneLineDesc#</p>
<p class="style2">'#eventList.Title#'</p>
<p class="style2">Organized by #eventList.Name#</p> </td>
</cfoutput>
This gives me the following output for the Top 3 items in the database:
Event Type
Event Date
Event Time
EVent Location
Event Speaker&Affiliation
Event Title
Event Organizer
What I would like this to do is to have the top item disappear after the time
has expired rather than the date. Many people like to see the next upcoming
event that same day rather than have to wait until the date expires. I am not
sure how to accomplish this and where the change should be placed in the code.
Thanks for the help.
Dan Bracuk - 30 Mar 2006 21:08 GMT
what are the datatypes for your eventdate and eventtime fields? If they are
date and time, do you have a function available that converts them to a
date/time? Also, do you have a date-time datatype available?
HMOKeefe - 30 Mar 2006 21:46 GMT
Eventdate is date/time while eventtime and eventimeto are both text strings. I
actually want the event to be removed after eventimeto. Rather than a function
eventtime strings are converted to date/time values using a series of linked
tables, DateDay, DateMonth and DateTimeFormat.
Dan Bracuk - 30 Mar 2006 23:29 GMT
Originally posted by: HMOKeefe
Eventdate is date/time while eventtime and eventimeto are both text strings. I
actually want the event to be removed after eventimeto. Rather than a function
eventtime strings are converted to date/time values using a series of linked
tables, DateDay, DateMonth and DateTimeFormat.
I assume that you are storing 00:00, or something equally meaningless as the
time portion of the eventdate. You could really simplify life by renaming it
to eventdatetimestart. Then add a field called eventdatetimeend. Populate
them with values that reflect the date and time the event is supposed to start
and end. Then you won't need those character fields or format tables.
If you had that now, this
AND EventDate>= #CreateODBCDate(now())#
would actually work.
On a related note, if your db has a function that returns the current date and
time, your application will run faster than using nested cold fusion functions.
It's a good habit to get into.