CFLib.org – Common Function Library Project

isOldEnough(dob, minAge)

Last updated January 2, 2004

author

Paul Malan

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Given a date of birth, determine whether a user is old enough to satisfy an arbitrary minimum age requirement. Accurate down to the day.

Return Values:
Returns a boolean.

Example:

<cfoutput>
isOldEnough('5/27/1977',18): #isOldEnough('5/27/1977',18)#<br>
isOldEnough('1/30/1995',13): #isOldEnough('1/30/1995',13)#
</cfoutput>

Parameters:

Name Description Required
dob Date of birth. Yes
minAge Age in years. Yes

Full UDF Source:

/**
 * Determine whether a date of birth exceeds minimum age requirement.
 * 
 * @param dob 	 Date of birth. (Required)
 * @param minAge 	 Age in years. (Required)
 * @return Returns a boolean. 
 * @author Paul Malan (paul@malan.org) 
 * @version 1, January 2, 2004 
 */
function isOldEnough(dob,minAge) {
	var goldenDate = dateAdd('yyyy', -minAge, now());
	if (datecompare(goldenDate,dob) gt 0) return true;
	else return false;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson