Skip to main content

How do I calculate participant age in Impact Hub reports?

Updated over a week ago

Age-based reporting is a common requirement when analyzing participant data. In Impact Hub, age is not stored as a static value. Instead, you calculate age using date fields (such as Date of Birth) and custom calculated fields in Builder.

This article provides example approaches you can use to calculate age in years or months, group participants into age ranges, or derive milestone dates like a participant’s 18th birthday.

Important things to know

  • Age calculations are created as calculated fields within a report.

  • Calculations do not change the underlying dataset or Apricot data.

  • You must update field names in examples to match your dataset.

  • Age calculations depend on valid date fields, such as Date of Birth.

  • Calculations can return numeric, string, or date values depending on how they’re written.

  • Only Impact Hub Authors and Author Pro users can create these calculations.

Choose the right age calculation approach

Before creating a calculation, decide what you need to report:

  • Current age (based on today’s date)

  • Age as of a specific date (such as enrollment date or a reporting cutoff)

  • Age ranges (for grouping or charts)

  • Age in months (commonly used for infants or young children)

  • Milestone dates (such as a participant’s 18th birthday)

Different reporting needs call for different calculation patterns.

Return a participant’s current age

Simple year-based age (approximate)

Use this approach when you need an approximate age in years for grouping or filtering.

dateDiff({Date of Birth}, now(), 'YYYY')
  • Output type: Numeric

  • Common uses: Filters, age bands, summary tables

This method uses year-based logic and is suitable when exact precision is not required.

Approximate age using days (more precise)

Use this approach when you want slightly more precision by calculating age using days.

floor(dateDiff({Date of Birth}, now(), 'DD') / 365.25)
  • Output type: Numeric

  • Common uses: KPIs, tables, comparisons

This method divides the number of days since birth by an average year length.

Calculate age as of a specific date

Sometimes you need age based on a fixed point in time rather than “today.” Instead of using now(), reference a specific date field (such as enrollment start date) or a fixed date value.

Age in years as of a specific date

This example calculates age based on the date of enrollment included in the dataset.

floor(
dateDiff({Date of Birth}, {Date of Enrollment}, 'DD') / 365.25
)

Output type: Numeric

Common uses: Eligibility logic, historical reporting, filters

Age in years as of a fixed date

This example calculates each participant’s age as of December 31, 2024.

When to use a fixed date like this:

  • Grant or funder reporting tied to a specific reporting period

  • Eligibility checks as of a cutoff date

  • Historical analysis where results should not change over time

floor(
dateDiff(
{Date of Birth},
parseDate('2024-12-31', 'yyyy-MM-dd'),
'DD'
) / 365.25
)

Group participants into age ranges

Age ranges make dashboards easier to read and interpret.

This approach assumes you already have a numeric age field and uses a conditional calculation to assign participants to labeled groups.

ifelse(
isNull({Age}), 'No Age Listed',
{Age} < 18, 'Under 18',
{Age} < 30, '18–29',
{Age} < 40, '30–39',
{Age} < 50, '40–49',
{Age} < 64, '50–64',
{Age} >= 65, 'Over 65',
'No Age Listed'
)

Output type: String

Common uses: Bar charts, legends, filters

Identify age in months for children under one year

For infant reporting, age in months is often more meaningful than age in years.

You can:

  • Calculate age in months as a numeric value

    • Output type: Numeric

    • Common uses: Tables, filters, charts

round(
dateDiff({Date of Birth}, now(), 'DD') / 30.4375,
1
)
  • Limit the calculation to children under one year

    • Output type: Numeric

    • Common uses: Conditional display, filtering

ifelse(
dateDiff({Date of Birth}, now(), 'DD') < 365,
round(dateDiff({Date of Birth}, now(), 'DD') / 30.4375, 1),
null
)
  • Display age in months as text for readability

    • Output type: String

    • Common uses: Labels, tables

concat(
toString(round(dateDiff({Date of Birth}, now(), 'DD') / 30.4375, 1)),
' months'
)

A common pattern is to display:

  • Age in months for participants under one year

  • Age in years for all other participants

ifelse(
isNull({Date of Birth}),
null,
dateDiff({Date of Birth}, now(), 'DD') < 365,
concat(
toString(round(dateDiff({Date of Birth}, now(), 'DD') / 30.4375, 1)),
' months'
),
concat(
toString(floor(dateDiff({Date of Birth}, now(), 'DD') / 365.25)),
' years'
)
)

This returns text (string) as a single, readable display field for tables and labels.

Note: If you'd rather show whole months with no decimals, replace round(..., 1) with floor(...).

ifelse(
isNull({Date of Birth}),
null,
dateDiff({Date of Birth}, now(), 'DD') < 365,
concat(
toString(floor(dateDiff({Date of Birth}, now(), 'DD') / 30.4375)),
' months'
),
concat(
toString(floor(dateDiff({Date of Birth}, now(), 'DD') / 365.25)),
' years'
)
)

Return the date of a participant’s 18th birthday

Some reporting scenarios require milestone dates rather than age values.

You can calculate a participant’s 18th birthday as a date field, which is useful for:

  • Eligibility checks

  • Compliance timelines

  • Filters or comparisons

addDateTime(18, 'YYYY', {Date of Birth})

Output type: Date
Common uses: Filters, comparisons, timelines

Note for leap year birthdays: For participants born on Feb 29, milestone dates calculated using addDateTime fall on Feb 28 in non-leap years.

The date format can be adjusted in Impact Hub once the calculated field has been added to a visual.

Tips for working with age calculations

  • Test age calculations in a table visual before using them in charts.

  • Use numeric age values for filtering and aggregation.

  • Use string-based age groupings for labels and legends.

  • Be explicit about whether age is calculated as of today or a specific date.

  • Expect small differences when using approximate month or year conversions.

Troubleshooting tips

If age calculations don’t behave as expected, check the following:

  • Does the dataset include a valid Date of Birth field?

  • Are date fields stored as date values (not text)?

  • Are field names referenced exactly as shown in the Fields list?

  • Is now() appropriate for your reporting context?

  • Do calculated ages match expected values for known records?

  • Do filters behave correctly when applied to age fields?

What else do you need help with?

Did this answer your question?