473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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

Expand|Select|Wrap|Line Numbers
  1. <cfset date_check=check_date(#Form.startDate#,#Form.endDate#)>
  2. <cfoutput>#date_check#</cfoutput>
  3. <cfif NOT isDefined("date_check")>
  4.     <li>Please make sure the end date comes after the start date.</li>
  5. </cfif>
  6.  
and my function is
Expand|Select|Wrap|Line Numbers
  1. <cffunction
  2.     name="check_date"
  3.     return type="boolean">
  4.  
  5.     <cfargument
  6.         name="start_date"
  7.         type="date"
  8.         required="yes">
  9.     <cfargument
  10.         name="end_date"
  11.         type="date"
  12.         required="yes">
  13.  
  14.     <cfif start_date lt end_date>
  15.         <cfset return_value=true>
  16.     <cfelse>
  17.         <cfset return_value=false>
  18.     </cfif>
  19.  
  20.     <cfreturn return_value>
  21. </cffunction>
  22.  
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("check_date(#Form.startDate#,#Form.endDa te#)") but that gave me an error.

Thanks.
Mar 28 '07 #1
1 3574
acoder
16,027 Expert Mod 8TB
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
Expand|Select|Wrap|Line Numbers
  1. <cfif date_check IS FALSE>
Mar 29 '07 #2

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.