CFLib.org – Common Function Library Project

GetCurrentAge(birthdate)

Last updated November 30, 2001

author

Eric Dobris

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());
}
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