318
CFML Language Reference
<P>The datecompare function compares two date/time values.
<CFIF IsDefined("FORM.date1")>
<CFIF IsDate(FORM.date1) and IsDate(FORM.date2)>
<CFSET comparison = DateCompare(FORM.date1, FORM.date2,
FORM.precision)>
<!--- switch on the variable to give various responses --->
<CFSWITCH EXPRESSION=#comparison#>
<CFCASE VALUE="-1">
<H3><CFOUTPUT>#DateFormat(FORM.date1)#
#TimeFormat(FORM.date1)#</CFOUTPUT> (Date 1) is
earlier than <CFOUTPUT>#DateFormat(FORM.date2)#
#TimeFormat(FORM.date2)#</CFOUTPUT> (Date 2)</H3>
<I>The dates are not equal</I>
</CFCASE>
<CFCASE VALUE="0">
<H3><CFOUTPUT>#DateFormat(FORM.date1)#
#TimeFormat(FORM.date1)#</CFOUTPUT> (Date 1) is equal
to <CFOUTPUT>#DateFormat(FORM.date2)#
#TimeFormat(FORM.date2)#</CFOUTPUT> (Date 2)</H3>
<I>The dates are equal!</I>
</CFCASE>
<CFCASE VALUE="1">
<H3><CFOUTPUT>#DateFormat(FORM.date1)#
#TimeFormat(FORM.date1)#</CFOUTPUT> (Date 1) is later
than <CFOUTPUT>#DateFormat(FORM.date2)#
#TimeFormat(FORM.date2)#</CFOUTPUT> (Date 2)</H3>
<I>The dates are not equal</I>
</CFCASE>
<CFDEFAULTCASE>
<H3>This is the default case</H3>
</CFDEFAULTCASE>
</CFSWITCH>
<CFELSE>
<H3>Please enter two valid date values</H3>
</CFIF>
</CFIF>
<FORM ACTION="datecompare.cfm" METHOD="POST">
<hr size="2" color="#0000A0">
<P>Date 1
<BR><INPUT TYPE="Text" NAME="date1" VALUE="<CFOUTPUT>#DateFormat(Now())#
#TimeFormat(Now())#
</CFOUTPUT>">
<P>Date 2
Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE
Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Page 584: ...560 CFMLLanguageReference...
Page 594: ...570 CFMLLanguageReference...