cffunctions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • celery6541
    New Member
    • Mar 2007
    • 15

    #1

    cffunctions

    Hi all,

    I am using a function to check two dates to make sure that an end date comes after a start date. Right now I am trying to call it like this

    Code:
    <cfset date_check=check_date(#Form.startDate#,#Form.endDate#)>
    <cfoutput>#date_check#</cfoutput>
    <cfif NOT isDefined("date_check")>
        <li>Please make sure the end date comes after the start date.</li>
    </cfif>
    and my function is
    Code:
    <cffunction
        name="check_date"
        return type="boolean">
       
        <cfargument
            name="start_date"
            type="date"
            required="yes">
        <cfargument
            name="end_date"
            type="date"
            required="yes">
        
        <cfif start_date lt end_date>
            <cfset return_value=true>
        <cfelse>
            <cfset return_value=false>
        </cfif>
    
        <cfreturn return_value>
    </cffunction>
    the cfoutput is showing the correct true/false values being produced by the function but the cfif statement isn't executing when date_check is false. Am I using the boolean evaluator incorrectly? Also, is there a way to put the function call into the IsDefined function? I tried IsDefined("chec k_date(#Form.st artDate#,#Form. endDate#)") but that gave me an error.

    Thanks.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Don't use isDefined. That's to check if the variable is defined which it obviously is. You need to check if it's false.

    Try
    Code:
    <cfif date_check IS FALSE>

    Comment

    Working...