containsLeapYear(startDate, endDate)
Last updated May 26, 2003
Version: 1 | Requires: CF5 | Library: DateLib
Description:
Function that determines if a given date range contains a leap year. Returns true if it contains a leap year, false if not.
Return Values:
Returns a boolean.
Example:
<CFOUTPUT>
containsLeapYear("1/1/2002", "6/1/2002") = #containsLeapYear("1/1/2002", "6/1/2002")#<br>
containsLeapYear("1/1/2003", "6/1/2003") = #containsLeapYear("1/1/2003", "6/1/2003")#<br>
containsLeapYear("1/1/2004", "2/1/2004") = #containsLeapYear("1/1/2004", "2/1/2004")#<br>
containsLeapYear("1/1/2004", "6/1/2004") = #containsLeapYear("1/1/2004", "6/1/2004")#<br>
</CFOUTPUT>
Parameters:
Name | Description | Required |
---|---|---|
startDate | Initial date. | Yes |
endDate | Ending date. | Yes |
Full UDF Source:
/**
* Function that determines if a given date range contains a leap year.
*
* @param startDate Initial date. (Required)
* @param endDate Ending date. (Required)
* @return Returns a boolean.
* @author Mosh Teitelbaum (mosh.teitelbaum@evoch.com)
* @version 1, May 26, 2003
*/
function containsLeapYear(startDate, endDate) {
// Build offsets
var StartDateYearOffset = DateAdd("yyyy", 1, startDate);
var StartDateYearOffsetInDays = DateDiff("d", startDate, StartDateYearOffset);
var EndDateYearOffset = DateAdd("yyyy", 1, Trim(endDate));
var EndDateYearOffsetInDays = DateDiff("d", endDate, EndDateYearOffset);
// Return result
return IIf(StartDateYearOffsetInDays - EndDateYearOffsetInDays GT 0, DE("true"), DE("false"));
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016