Many apps require knowing a person’s age, whether it’s for managing employee records, event registrations, or customer details. Power Apps makes it easy to calculate age based on a birthday.
In this tutorial, I will discuss how to calculate age in Power Apps, including years, months, and days, with various formulas.
So let’s get started!
Calculate Age in Power Apps
In this example, we’ll use a date picker control. The user can select a date, such as their birthday, and the app will calculate their age and display it on a label.
The age is calculated automatically by comparing today’s date with the birthday they select.
To do this, I’ll use two different formulas below:
Code – 1:
Select the Label control and apply the following formula to its Text property:
"Age: " & DateDiff(
dtSelectDate.SelectedDate,
Today(),
TimeUnit.Years
)
OR
"Age: " & DateDiff(
dtSelectDate.SelectedDate,
Now(),
TimeUnit.Years
)
Where,
- “Age: ” = This is the string that I want to display in the label control
- dtSelectDate = Name of the Date Picker control
Also, you can refer to the screenshot below.

Code – 2:
In the same way, select the Label control and set the below code on its Text property as:
"Age: " & If(
DateDiff(
Today(),
Date(
Year(Now()),
Month(dtSelectDate),
Day(dtSelectDate)
)
) <= 0,
DateDiff(
dtSelectDate,
Today(),
Years
),
DateDiff(
dtSelectDate,
Today(),
Years
) - 1
)
Where,
dtSelectDate = Specify the date picker control name

Finally, save and preview the app. Select any date from the date picker, and you can see the age on the label.
Power Apps Calculate Age Based On Specified Time Unit (Years, Months, Days)
Next, we will discuss how to calculate the age difference based on the specified time unit, either in years, months, or days.
Here, in the image below, I have taken a Modern date picker and a label control. When the user selects a specific date from the date picker, the result will display in years, months, and days.

To achieve this, select the Label and set its Text property as:
If(
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Days
) < 365,
Concatenate(
"0 years ",
Int(
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Days
) / 30
),
" Months ",
Int(
Mod(
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Days
),
30
)
),
" days"
),
Concatenate(
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Years
),
" Years"
)
)
Where,
- DateDiff(date1, date2, timeunit): This function calculates the difference between two dates based on the specified time unit (Years, Months, Days, etc.).
- DatePickerCanvas1: Modern Date picker control name.
- Today(): Returns the current date.
- Years, Months, Days: Specify the time unit for the difference.
- Int(): Converts a decimal number to an integer (whole number).
- Mod(): Returns the remainder of a division.
- Concatenate(): Joins text strings together.

Save, publish, and preview the app. Select any specific date from the modern date picker control, and the age will be calculated and displayed on the label.
Calculate Age in Power Apps With Years, Months, Days
To accurately calculate age in Power Apps with years, months, and days, we’ll need to compare the selected birthdate with today’s date carefully.

Let’s copy the code below and paste it into the Label’s Text property: (replace your Date picker control name)
With(
{
birth: DatePickerCanvas1.SelectedDate,
today: Today(),
totalYears: DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Years
),
birthdayThisYear: DateAdd(
DateValue(
Text(
Today(),
"[$-en-US]yyyy"
) & "-" & Text(Month(DatePickerCanvas1.SelectedDate)) & "-" & Text(Day(DatePickerCanvas1.SelectedDate))
),
0
),
adjustYear: If(
Today() < DateAdd(
DateValue(
Text(
Today(),
"[$-en-US]yyyy"
) & "-" & Text(Month(DatePickerCanvas1.SelectedDate)) & "-" & Text(Day(DatePickerCanvas1.SelectedDate))
),
0
),
-1,
0
),
years: DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Years
) + If(
Today() < DateAdd(
DateValue(
Text(
Today(),
"[$-en-US]yyyy"
) & "-" & Text(Month(DatePickerCanvas1.SelectedDate)) & "-" & Text(Day(DatePickerCanvas1.SelectedDate))
),
0
),
-1,
0
),
yearAdjustedDate: DateAdd(
DatePickerCanvas1.SelectedDate,
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Years
) + If(
Today() < DateAdd(
DateValue(
Text(
Today(),
"[$-en-US]yyyy"
) & "-" & Text(Month(DatePickerCanvas1.SelectedDate)) & "-" & Text(Day(DatePickerCanvas1.SelectedDate))
),
0
),
-1,
0
),
TimeUnit.Years
),
months: DateDiff(
DateAdd(
DatePickerCanvas1.SelectedDate,
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Years
) + If(
Today() < DateAdd(
DateValue(
Text(
Today(),
"[$-en-US]yyyy"
) & "-" & Text(Month(DatePickerCanvas1.SelectedDate)) & "-" & Text(Day(DatePickerCanvas1.SelectedDate))
),
0
),
-1,
0
),
TimeUnit.Years
),
Today(),
TimeUnit.Months
),
monthAdjustedDate: DateAdd(
DateAdd(
DatePickerCanvas1.SelectedDate,
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Years
) + If(
Today() < DateAdd(
DateValue(
Text(
Today(),
"[$-en-US]yyyy"
) & "-" & Text(Month(DatePickerCanvas1.SelectedDate)) & "-" & Text(Day(DatePickerCanvas1.SelectedDate))
),
0
),
-1,
0
),
TimeUnit.Years
),
DateDiff(
DateAdd(
DatePickerCanvas1.SelectedDate,
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Years
) + If(
Today() < DateAdd(
DateValue(
Text(
Today(),
"[$-en-US]yyyy"
) & "-" & Text(Month(DatePickerCanvas1.SelectedDate)) & "-" & Text(Day(DatePickerCanvas1.SelectedDate))
),
0
),
-1,
0
),
TimeUnit.Years
),
Today(),
TimeUnit.Months
),
TimeUnit.Months
),
days: DateDiff(
DateAdd(
DateAdd(
DatePickerCanvas1.SelectedDate,
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Years
) + If(
Today() < DateAdd(
DateValue(
Text(
Today(),
"[$-en-US]yyyy"
) & "-" & Text(Month(DatePickerCanvas1.SelectedDate)) & "-" & Text(Day(DatePickerCanvas1.SelectedDate))
),
0
),
-1,
0
),
TimeUnit.Years
),
DateDiff(
DateAdd(
DatePickerCanvas1.SelectedDate,
DateDiff(
DatePickerCanvas1.SelectedDate,
Today(),
TimeUnit.Years
) + If(
Today() < DateAdd(
DateValue(
Text(
Today(),
"[$-en-US]yyyy"
) & "-" & Text(Month(DatePickerCanvas1.SelectedDate)) & "-" & Text(Day(DatePickerCanvas1.SelectedDate))
),
0
),
-1,
0
),
TimeUnit.Years
),
Today(),
TimeUnit.Months
),
TimeUnit.Months
),
Today(),
TimeUnit.Days
)
},
Concatenate(
years,
" years, ",
months,
" months, ",
days,
" days"
)
)
Refer to the image below:

I hope this guide helped you understand how to calculate age in Power Apps. Also, we covered how to work with Power Apps to calculate age based on specified time units, including Years, Months, and Days, with various examples.
Additionally, you may like some more Power Apps articles:
- Create a Responsive Navigation Menu in Power Apps
- Power Apps LastSubmit()
- Build a Calculator in Power Apps
- Power Apps Gallery Row Number
- Hide Power Apps Combo Box Choice Value Based On Text Input

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.