Skip navigation
Currently Being Moderated

cfif variable is query values

Jun 24, 2012 7:25 PM

Hi all,

In the last section of the code I am testing to see if meetingdate is a holiday, what is the correct way to do it , am I on the right track? Thanks

 

<!--- QUERY TO GET HOLIDAY DATES --->
<CFQUERY name="hols" datasource="salesdb">
SELECT holiday, holidayid FROM holidays
</CFQUERY>

<!--- SET MEETINGDATE ACCORDING TO DAY OF THE WEEK --->
<cfset meetingDate = trim(form.meeting)>
<cfif not isDate(meetingDate)>
<cfif DayOfWeek(Now()) eq 2>
<cfset meetingDate = dateAdd("d", 2, now())>
<cfelseif DayOfWeek(Now()) eq 3>
<cfset meetingDate = dateAdd("d", 2, now())>
<cfelseif DayOfWeek(Now()) eq 4>
<cfset meetingDate = dateAdd("d", 2, now())>

 

</cfif>
</cfif>

 

<!--- NOW CHECK IF NEW MEETINGDATE IS A HOLIDAY AND ADD DAYS--->

<cfif meetingDate = hols.holiday >
<cfif meetingDate eq 2>
<cfset meetingDate = dateAdd("d", 3, now())>
<cfelseif meetingDate eq 3>
<cfset meetingDate = dateAdd("d", 3, now())>
<cfelseif meetingDate eq 4>
<cfset meetingDate = dateAdd("d", 2, now())>

 

</cfif>

 
Replies
  • Currently Being Moderated
    Jun 25, 2012 5:14 AM   in reply to goodychurro1

    You appear to be missing a function call in the bottom part of your code.  It also appears to be incomplete.  You don't have anything for Thursday and Friday.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2012 9:37 AM   in reply to goodychurro1

    If you want the code to be easier to read, consider using switch/case instead of if/else if/else. 

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2012 8:27 PM   in reply to goodychurro1

    Why not? 

     

    You are checking to see if '2012-12-25' is 2, 3, 4, 5, 6, 7, or 1,  Which one did you expect to return true?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points