Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Explorer ,
Jan 27, 2012 Jan 27, 2012
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>

821
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 27, 2012 Jan 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2012 Jan 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)>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 29, 2012 Jan 29, 2012
LATEST

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

<cfoutput query="xxxx">

     <cfif>

     <cfelse>

     </cfif>

</cfouput>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources