I have three dates, and need to check the dates for these criterias:
1. End_Date cannot be earlier then or equal to Start_Date
2. End_Date cannot be later then or equal to Expire_Date
3. Expire_Date cannot be earlier then or equal to Start_Date
4. Expire_Date cannot be earlier then or equal to End_Date
This is how I am doing it, but seems like a lot of work. Is there a better (and quicker) way?
Thanks.
____________________________________
Just Imagine.
1. End_Date cannot be earlier then or equal to Start_Date
2. End_Date cannot be later then or equal to Expire_Date
3. Expire_Date cannot be earlier then or equal to Start_Date
4. Expire_Date cannot be earlier then or equal to End_Date
This is how I am doing it, but seems like a lot of work. Is there a better (and quicker) way?
Thanks.
Code:
<cfif isdate(FORM.Start_Date) and isdate(FORM.End_Date)>
<cfset comparison = datecompare(FORM.End_Date, FORM.Start_Date)>
<cfswitch expression="#comparison#">
<cfcase value="-1">
<!--- 'FORM.End_Date' IS EARLIER THEN OR EQUAL TO 'FORM.Start_Date' --->
<cflocation url="" addtoken="no">
</cfcase>
<cfcase value="0">
<!--- 'FORM.End_Date' IS EARLIER THEN OR EQUAL TO 'FORM.Start_Date' --->
<cflocation url="" addtoken="no">
</cfcase>
</cfswitch>
</cfif>
<cfif isdefined("FORM.Expire_Date")>
<cfif (isdate(FORM.Start_Date) and isdate(FORM.Expire_Date)) or (isdate(FORM.End_Date) and isdate(FORM.Expire_Date))>
<cfset comparison = datecompare(FORM.Expire_Date, FORM.Start_Date)>
<cfset comparison2 = datecompare(FORM.Expire_Date, FORM.End_Date)>
<cfswitch expression="#comparison#">
<cfcase value="-1">
<!--- 'FORM.Expire_Date' IS EARLIER THEN OR EQUAL TO 'FORM.Start_Date' --->
<cflocation url="" addtoken="no">
</cfcase>
<cfcase value="0">
<!--- 'FORM.Expire_Date' IS EARLIER THEN OR EQUAL TO 'FORM.Start_Date' --->
<cflocation url="" addtoken="no">
</cfcase>
</cfswitch>
<cfswitch expression="#comparison2#">
<cfcase value="-1">
<!--- 'FORM.Expire_Date' IS EARLIER THEN OR EQUAL TO 'FORM.End_Date' --->
<cflocation url="" addtoken="no">
</cfcase>
<cfcase value="0">
<!--- 'FORM.Expire_Date' IS EARLIER THEN OR EQUAL TO 'FORM.End_Date' --->
<cflocation url="" addtoken="no">
</cfcase>
</cfswitch>
</cfif>
</cfif>
____________________________________
Just Imagine.