CFLib.org – Common Function Library Project

isOldEnough(dob, minAge)

Last updated January 02, 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;
}

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

Created by Raymond Camden / Design by Justin Johnson