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:
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
DateDiff(DateTimeValue(SelectedDate),Now(),Years)
If(DateDiff(Today(), Date(Year(Now()), Month(birth), Day(birth))) <= 0, DateDiff(birth, Today(), Years), DateDiff(birth, Today(), Years) - 1)
this formula is working
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).
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.
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
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.
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,079
Most Valuable Professional