GetCurrentAge(birthdate)
Last updated November 30, 2001
Version: 1 | Requires: CF5 | Library: DateLib
Description:
This UDF uses a persons birthdate to output their current age in years. This will output a non negative inter value - unless of course you enter a birthdate in the future.
Return Values:
Returns a numeric value.
Example:
<CFSET BirthDate = "01/01/98">
<cfoutput>
Birthdate: #BirthDate#<BR>
Age: #GetCurrentAge(BirthDate)#
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
birthdate | Valid date object representing a person's birth date. | Yes |
Full UDF Source:
/**
* This UDF uses a persons birthdate to output their current age in years.
* 11/30/01 - Optimize code: Sierra Bufe (sierra@brighterfusion.com)
*
* @param birthdate Valid date object representing a person's birth date.
* @return Returns a numeric value.
* @author Eric Dobris (swooosh2@hotmail.com)
* @version 1, November 30, 2001
*/
function GetCurrentAge(birthdate){
return datediff('yyyy',birthdate,now());
}
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