cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Dpalmer
Level: Powered On

Calculate Years and Months Between Two Dates

Hello,

 

I am using the DateDiff() function to calculate the number of months between two dates. An example:

 

DateDiff(DateValue(Label43_20.Text),Today(),Months)

 

However, I want the result to be displayed not in months, but in years and months. So for example, if the difference in months were 14, I want the output to be "1Y 2M"

 

Any help would be appreciated,

Thanks,
David

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Calculate Years and Months Between Two Dates

Hi @Dpalmer 

 

Can you try to use below expression for getting the value:
 
DateDiff(DateValue(Label43_20.Text),Today(),Years)&"Y "&Mod(DateDiff(DateValue(Label43_20.Text),Today(),Months),12)&"M"
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
2 REPLIES 2
Super User
Super User

Re: Calculate Years and Months Between Two Dates

Hi @Dpalmer 

 

Can you try to use below expression for getting the value:
 
DateDiff(DateValue(Label43_20.Text),Today(),Years)&"Y "&Mod(DateDiff(DateValue(Label43_20.Text),Today(),Months),12)&"M"
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Dpalmer
Level: Powered On

Re: Calculate Years and Months Between Two Dates

Thank you! Forgot about Mod().  Works perfectly.

David

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 45 members 4,144 guests
Please welcome our newest community members: