web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Calculate Age in Power...
Power Apps
Answered

Calculate Age in Power Apps

(1) ShareShare
ReportReport
Posted on 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

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    eka24 Profile Picture
    20,923 on at

    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.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    It’s not as simple as it looks because age is typically rounded down.  I did it for cds here https://powerusers.microsoft.com/t5/Microsoft-Dataverse/Calculating-age-in-CDS-entity/td-p/495528 

  • Radoslavov Profile Picture
    817 on at

    This is working,I just change the formula slightly to remove the age rounding as 29 years and 9 months even if it's close to 30, the medical records think otherwise when it comes to accuracy.

  • Verified answer
    MartinVasek Profile Picture
    30 on at

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

  • PapithaSekar1 Profile Picture
    100 on at

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

    this formula is working

  • Epzone Profile Picture
    3 on at

    DateDiff(DateTimeValue(SelectedDate),Now(),Years)

  • fatima12345 Profile Picture
    2 on at

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard