<!--- This example shows the use of datecompare --->
<HTML>

<HEAD>
<TITLE>
DateCompare Example
</TITLE>
</HEAD>

<BASEFONT FACE="Arial, Helvetica" SIZE=2>

<BODY  bgcolor="#FFFFD5">

<H3>DateCompare Example</H3>

<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)>

<HR size="2" color="#0000A0">
<!--- 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
<BR><INPUT TYPE="Text" NAME="date2" VALUE="<CFOUTPUT>#DateFormat(Now())# #TimeFormat(Now())#</CFOUTPUT>">

<P>Specify precision to the:
<BR><SELECT NAME="precision">
			<OPTION VALUE="s">
				Second
			</OPTION>	
			<OPTION VALUE="n">
				Minute
			</OPTION>	
			<OPTION VALUE="h">
				Hour
			</OPTION>	
			<OPTION VALUE="d">
				Day
			</OPTION>
			<OPTION VALUE="m">
				Month
			</OPTION>	
			<OPTION VALUE="yyyy">
				Year
			</OPTION>													
	</SELECT>

<P><INPUT TYPE="Submit" VALUE="Compare these dates" NAME=""> <INPUT TYPE="RESET">

</FORM>


</BODY>

</HTML>       
