Skip to main content

core.calculateage

Home > @medplum/core > calculateAge

calculateAge() function

Calculates the age in years from the birth date.

Signature:

export declare function calculateAge(birthDateStr: string, endDateStr?: string): {
years: number;
months: number;
days: number;
};

Parameters

ParameterTypeDescription
birthDateStrstringThe birth date or start date in ISO-8601 format YYYY-MM-DD.
endDateStrstring(Optional) Optional end date in ISO-8601 format YYYY-MM-DD. Default value is today.

Returns:

{ years: number; months: number; days: number; }

The age in years, months, and days.