Skip to main content
Inspiring
January 27, 2012
Question

Having activities/program date disappear from a <cfif> Statement...

  • January 27, 2012
  • 3 replies
  • 872 views
I would like to have different conferences or events disappear after the "createdatetime" variable of the event has met  the condition i had set in my cfif statement. The problem i am running into is that when i set my "<cfif #now()# gte", the date of my event, i want the particular event to remove itself from being displayed on the webpage. Howver all of the events that are less than and greater than that the #now()# variable date removes themselves from displaying on the webpage as well. Am i using the right syntax? Is there a way to modify this syntax so that only the date for the event that meet the requirement of the cfif statement stop displaying and nothing else? Below is the syntax i used:

<cfif #now()# gte "CreateDateTime (event.evebeginyear, event.evebeginmonth, event.evebeginday, event.evebeginhour, event.evebeginminute, event.evebeginsecond)" ><cfelse>

<cfoutput query="events">

Events from Database of various past an present dates

/cfoutput></cfif>

    This topic has been closed for replies.

    3 replies

    Prasanth_Kumar_S
    Inspiring
    January 30, 2012

    I think the logic is applied above the loop. It should be inside the loop like:

    <cfoutput query="xxxx">

         <cfif>

         <cfelse>

         </cfif>

    </cfouput>

    BKBK
    Community Expert
    Community Expert
    January 29, 2012

    <cfif #now()# gte "CreateDateTime (event.evebeginyear, event.evebeginmonth, event.evebeginday, event.evebeginhour, event.evebeginminute, event.evebeginsecond)" >

    No, this syntax is incorrect. The left-hand side of the GTE operator is a date object, whereas the right-hand side is a string. Correct is:

    <cfif now() gte createDateTime (event.evebeginyear, event.evebeginmonth, event.evebeginday, event.evebeginhour, event.evebeginminute, event.evebeginsecond)>

    Inspiring
    January 27, 2012

    You might be better off applying this logic to the query instead of the display.  If the intent is to display events in the future and nothing else, why bring back events from the past in your query?