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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Simple way to get year...
Power Apps
Answered

Simple way to get year(s), month(s), and day(s) between two dates?

(0) ShareShare
ReportReport
Posted on by 664

I have two values stored as dates. Given the example values 3/16/2020 and 3/17/2021, the value I'd like to show is 1 year(s) 0 month(s) 1 day(s).

 

I realize I could use the DateDiff and Mod functions and then subtraction to get this but is there a more elegant way to accomplish this?

Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    69,543 Most Valuable Professional on at

    I haven't seen a more refined way to do it than using Mod()  Here are the formulas I use for Days, Hours, and Minutes in a component I built.  You can easily extrapolate them to Years, Months, Days.

    Days = RoundDown(DateDiff(Component1.StartDate,Component1.TargetDate,Minutes)/1440,0)
    Hours = Mod(DateDiff(Component1.StartDate,Component1.TargetDate,Hours),24)
    Minutes = Mod(DateDiff(Component1.StartDate,Component1.TargetDate,Minutes),60)

     

  • Pedexman Profile Picture
    25 on at

    Hi Pstork1,

     

    Can you share how you would get the Years, Month and Day please. I have been looking how to figure this out also.

     

    Thanks

  • Pstork1 Profile Picture
    69,543 Most Valuable Professional on at

    Please post this as a new question.  You'll get more responses and others will be able to find the answer more easily later. The code to get the Years, months, and days from a specific date is there in the answer. So I'm not sure what you are asking for.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 421

#2
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 278 Super User 2026 Season 1

Last 30 days Overall leaderboard