Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFIF Date Parameter 1

Status
Not open for further replies.

monoone

Programmer
May 24, 2002
219
0
0
US
Hello;

I am trying to have an Event Date disappear 1 day after the event date by CFIF.

Here is the code but nothing is appearing. Note, the query works fine if I omit the CFIF but it shows all the events past and present.

------------------------------
CODE
------------------------------
<cfif #now()# lte DateFormat(#EarCandy.GigDate#, 'ddd, mmmm dd, yyyy')>
<cfoutput query="EarCandy">
#DateFormat(GigDate, 'ddd, mmmm dd, yyyy')#<br>
<cfif #trim(BandURL)# IS NOT ""><a href=" target="_blank">#BandName#</a><cfelse>#BandName#</cfif><br>
<cfif STYLE IS NOT "">#Style#<br><CFELSE></CFIF>
<cfif #trim(VenueURL)# IS NOT ""><a href=" target="_blank">#VenueName#</a><cfelse>#VenueName#</cfif><br>
#VenueCity#, #VenueState#<br>
<cfif STYLE IS NOT "">#VenuePhone#<br><CFELSE></CFIF>
#EarCatName#<br>
<br><br>
</cfoutput>
</CFIF>
-------------------------------
CODE
-------------------------------

Thanks,

Eric
 
your initial CFIF compares a date to a string

but i think the real problem is that you are looking at the first row of the query results

what ORDER BY does the query use?

rudy
SQL Consulting
 
Here is The Query:
------------------------
<CFQUERY NAME="EarCandy" DATASOURCE="JamDB" DBTYPE="ODBC">

SELECT
b.BandName, b.BandURL, b.Style,
v.VenueName, v.VenueCity, v.VenueState,
v.VenueURL, v.VenuePhone,
ec.GigDate,
cat.EarCatName
FROM
EarCandy ec, Band b, EarCat cat, Venue v

WHERE
b.BandID = ec.BandID AND
v.VenueID = ec.VenueID AND
cat.EarCatID = ec.EarCatID


ORDER BY GigDate ASC
</CFQUERY>

-------------------------------------
 
okay, ORDER BY GigDate ASC means that the oldest date comes first

then when you say

<cfif #now()# lte
DateFormat(#EarCandy.GigDate#, 'ddd, mmmm dd, yyyy')>

you are comparing today's date to the oldest date in the query results

make sense?

rudy
SQL Consulting
 
Actually what I want to do is Compare the Date of the event with today's date.


So:

-------- Would Not Show-------
Event 3
10/08/2004
------------------------------

----------Will Show-----------
Event 2
10/09/2004

Event 3
10/14/2004

-------------------------------

So the Code would be checking the system's date then comparing it to the date of the event. If the date of the event is lesser than the system's date it will not show.

If the system's date is greater or equal of the event date it will show.
---------------------------------

I tried the code above and it did not work.
------------------------------------------

<cfif #now()# lte DateFormat(#EarCandy.GigDate#, 'ddd, mmmm dd, yyyy')>
<cfoutput query="EarCandy">

#DateFormat(GigDate, 'ddd, mmmm dd, yyyy')#<br>
<cfif #trim(BandURL)# IS NOT ""><a href=" target="_blank">#BandName#</a><cfelse>#BandName#</cfif><br>
<cfif STYLE IS NOT "">#Style#<br><CFELSE></CFIF>
<cfif #trim(VenueURL)# IS NOT ""><a href=" target="_blank">#VenueName#</a><cfelse>#VenueName#</cfif><br>
#VenueCity#, #VenueState#<br>
<cfif STYLE IS NOT "">#VenuePhone#<br><CFELSE></CFIF>
#EarCatName#<br>
<br><br>

</cfoutput>
</CFIF>
---------------------------------------------
 
okay, that makes sense

what you have to do is move the CFIF inside the CFOUTPUT

<cfif now() lte GigDate>
#DateFormat(GigDate, 'ddd, mmmm dd, yyyy')#<br>
<cfif len(trim(BandURL))>
<a href=" target="_blank">#BandName#</a>
<cfelse>#BandName#</cfif><br>
<cfif len(Style)>#Style#<br><cfelse></cfif>
<cfif len(trim(VenueURL))>
<a href=" target="_blank">#VenueName#</a>
<cfelse>#VenueName#</cfif><br>
#VenueCity#, #VenueState#<br>
<cfif len(VenuePhone)>#VenuePhone#<br></cfif>
#EarCatName#<br>
<br><br>
</cfif>
</cfoutput>

rudy
SQL Consulting
 
thanks, and i even goofed in copy/paste, i forgot the opening line which was the cfoutput

rudy
SQL Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top