Logo
Home Cart [Log In] About Us Contact Us

Object Reference

xf_GeneralGeneral Functions

Public Function GetAgeInt (
vDOB As Variant,
Optional AsAtDate As Date = 0
) As Integer

Get age as specified date given date of birth.
This is not as easy as it might seem: DateDiff("y", DOB, Date) does not work. GetAgeInt is used in recordsets like this: Age: IIf(IsNull(DOB), Null, GetAgeInt(DOB)) as the variant-returning GetAge function gets cast to a string if there are any nulls in the column, which causes DataLists to sort age using string order rather then integer. This strong-type-returning function will not be cast to a string.
Returns -1 if the DOB cannot be converted to a valid date.

vDOB as Variant

Either Null or the Date of Birth as a Date or String.

Optional AsAtDate as Date = 0

The optional date at which to calculate age. Defaults to today.

Call Template:

Dim i As Integer
i = xf.Gen.GetAgeInt(vDOB)
i = xf.Gen.GetAgeInt(vDOB, AsAtDate)

See Also:

Example 1:

GetAge ("21 Sep 1970", #1 Jan 2014#) => 44
Contact Us :: About Us :: Policies :: email: infspamo@arrospamw-of-tispamme.com    © 2012 Arrow Of Time Pty Ltd