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

Parameter

Type

Description

birthDateStr

string

The birth date or start date in ISO-8601 format YYYY-MM-DD.

endDateStr

string

(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.