isUsefulDate(date)
Last updated July 25, 2012
Version: 1 | Requires: CF5 | Library: DateLib
Description:
isUsefulDate() tests for valid dates, but also tests that the date is within a century of now. Why? Dates outside that range are probably fat-fingered so you have a year of "201" or "20100" instead of "2010". Unless you are a historian or a futurist, you probably don't use dates beyond a hundred years of now; but if you do, feel free to increase the 100-year test in the UDF.
Return Values:
Returns a boolean
Example:
isUsefulDate("blah")=false
isUsefulDate("9/14/201")=false
isUsefulDate("9/14/2010")=true
isUsefulDate("9/14/20100")=false
Parameters:
Name | Description | Required |
---|---|---|
date | The value to test | Yes |
Full UDF Source:
/**
* Tests if a date is valid, and within a century of today.
* version 1.0 by Alan McCollough
*
* @param date The value to test (Required)
* @return Returns a boolean
* @author Alan McCollough (amccollough@anthc.org)
* @version 1, July 25, 2012
*/
function isUsefulDate(date){
if(isDate(date)){
if(abs(dateDiff("yyyy",date,now())) LTE 100)
return true;
else
return false;
}
else
return 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