Datecompare - MACROMEDIA COLDFUSION MX 61-CFML Reference

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

DateCompare

Description
Performs a full date/time comparison of two dates.
Returns
-1, if date1 is less than date2
0, if date1 is equal to date2
1, if date1 is greater than date2
Category
Date and time functions
Function syntax
DateCompare("date1", "date2" [, "datePart"])
See also
CreateDateTime,
Parameters
Parameter
date1
date2
datePart
Usage
When passing a date/time object as a string, you must enclose it in quotation marks. Otherwise, it
is interpreted as a numeric representation of a date/time object.
Example
<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)>
<!--- 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">
DatePart
Description
Date/time object, in the range 100 AD–9999 AD.
Date/time object, in the range 100 AD–9999 AD.
Optional. String. Precision of the comparison.
• s Precise to the second (default)
• n Precise to the minute
• h Precise to the hour
• d Precise to the day
• m Precise to the month
• yyyy Precise to the year
DateCompare
441

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents