web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details
Power Apps - Building Power Apps
Answered

Calculate Age in Power Apps

Like (1) ShareShare
ReportReport
Posted on 9 Feb 2021 13:22:30 by 817

Hi All,

 

It's being quite some time since my last question here and I'm seeking all professional's assistance here.

 

I'm building a Medical App that requires the Patient's age.

What is required from the Patient to enter is just his Sex and Date of Birth, the age will be calculated automatically using Todays Data and the Birthday Data input from the Calendar 

 

This is how the screen looks like:

Radoslavov_0-1612876640423.png

The Age number is actually the main information required for the app, so this file will be hidden from the user anyway.

Any suggestions on how to calculate the Age of a Patient?

I've tried this: DateDiff(Today(),userbirthdate.SelectedDate)

but I got the difference in days

Radoslavov_1-1612876805899.png

Radoslavov_2-1612876925851.png

 

 

 

  • Verified answer
    MartinVasek Profile Picture
    30 on 11 Jun 2021 at 11:34:47
    Re: Calculate Age in Power Apps

    This solution looks incorrect!

     

    It returns difference between current year and year of birth but NOT age.

    For example if today is 3rd of February 2022 and someone was born on 1st of January 2000, it will return the same result as for someone born on 3rd of March 2000. Ages are obviously different (22 and 21) but for both it returns 22.

     

    For return of age I recommend to use this:

    If(DateDiff(Today(), Date(Year(Now()), Month(birth), Day(birth))) <= 0, DateDiff(birth, Today(), Years), DateDiff(birth, Today(), Years) - 1)

     

    What it does:

    It checks if desired date's day and month are lower or equal to today's day and month and if so it makes difference between years. Otherwise it makes difference between this year and desired date year and deducts 1 (because this person didn't have birthday this year yet). 

  • Verified answer
    eka24 Profile Picture
    20,921 on 09 Feb 2021 at 14:19:13
    Re: Calculate Age in Power Apps

    Consider this:

    DateDiff(StartDatePicker.userbirthdate,Today(),Years)

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Helpful resources

Quick Links

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473