I could not find a simple solution to calculating age in a model driven app using a CDS entity because there is no RoundDown() function like there is in Canvas apps. I was able to accomplish it by using two fields to create the third. crabe_dob is the Date of Birth field in the entity. The first field (Age0) was a whole number calculated field with the formula
DiffInDays(crabe_dob, Now()) / 365
This created a whole number that was automatically rounded up.
The second field (Age1) was a decimal field with the same formula.
The third field (Age) was a whole number field contained the following conditional formula
If Age0 is greater than Age1 then Set Age to Age1 - 1 Else Set Age to Age0
Hi @Drrickryp ,
I agree with your solution. Thanks for your sharing. If you have other questions about PowerApps, please feel free to reply here.
Thanks for posting the solution. There is one edge case where it may not work though, as it doesn't take into account leap years. A closer function would be the following, assuming that you're dealing with people who are currently alive (as the year 2000 is a leap year, but 1900 is not)
DiffInDays(crabe_dob, Now()) / 365.25
Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.
Your chance to join an engaging competition of Power Platform enthusiasts.
The Super User program for 2022 - Season 2 has kicked off!
Attend in person or online, there are incredible conferences and events happening all throughout the month of September.