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 Apps
Answered

DATEDIFF

(0) ShareShare
ReportReport
Posted on by 162

GOOD DAY!

Anyone can help me?
about this problem in DATEDIFF

=DatedDiff(start_date,end_date+1,"y")
=DatedDiff(start_date,end_date+1,"ym")
=DatedDiff(start_date,end_date+1,"md")

in powerapps ivied  try so many solution
and did not get exactly the result 

😞

Categories:
  • eka24 Profile Picture
    20,925 on at

    If you are using a datepicker, add SelectedDate to the formula like:

    For Days:

    DateDiff(start_date.SelectedDate,end_date.SelectedDate)
     
    If you want the result in months or years:
    DateDiff(start_date.SelectedDate,end_date.SelectedDate,Months)
    DateDiff(start_date.SelectedDate,end_date.SelectedDate,Years)
     
    Please explain further the Plus +1 and the "yy" or "md"
    Do you want to add 1 year , 1 day or 1 month?
    ------------

    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.
  • DHAGZ Profile Picture
    162 on at

    @eka24 
    I want to add (+1) in End date 

  • eka24 Profile Picture
    20,925 on at

    Since your format is in year, month and day, i asked whether the +1 is to add 1 day 1 year or 1 month?

    ------------

    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. 

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @DHAGZ :

    Could you tell me what the meaning of "+1" is?I assume you want to add one more day.

    Could you tell me :

    • What is "ym"?I assume you want to get the number of years and months of the interval.
    • What is "md"?I assume you want to get the number of months and days between intervals

    DatedDiff(start_date,end_date+1,"y")

    DateDiff(start_date,DateAdd(end_date,1,Days),Years)

     DatedDiff(start_date,end_date+1,"ym")

    RoundDown(DateDiff(start_date,DateAdd(end_date,1,Days),Months)/12,0)&"Y"&Mod(DateDiff(start_date,DateAdd(end_date,1,Days),Months),12)&"M"

     DatedDiff(start_date,end_date+1,"md")

    RoundDown(DateDiff(start_date,DateAdd(end_date,1,Days),Days)/30,0)&"Y"&Mod(DateDiff(start_date,DateAdd(end_date,1,Days),Days),12)&"D" /*This method is not particularly accurate, because there are four possibilities of 28, 19, 30, and 31 days in a month*/

    1.JPG

    Best Regards,

    Bof 

  • DHAGZ Profile Picture
    162 on at
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @DHAGZ :

    Please try this formula:

    "It is "&DateDiff(start_date,DateAdd(end_date,1,Days),Days)&" days from the start date to the end date, end date included.
    
    Or "&RoundDown(DateDiff(start_date,DateAdd(end_date,1,Days),Months)/12,0)&" years, "&If(Day(end_date)-Day(start_date)+1>=0,Mod(DateDiff(start_date,DateAdd(end_date,1,Days),Months),12),Mod(DateDiff(start_date,DateAdd(end_date,1,Days),Months),12)-1)&" months, "&If(Day(end_date)-Day(start_date)+1>=0,Day(end_date)-Day(start_date)+1,DateDiff(start_date,Date(Year(DateAdd(start_date,1,Months)),Month(DateAdd(start_date,1,Months)),1),Days)+Day(end_date))&" days including the end date.
    
    Or "&If(Day(end_date)-Day(start_date)+1>=0,DateDiff(start_date,DateAdd(end_date,1,Days),Months),DateDiff(start_date,DateAdd(end_date,1,Days),Months)-1)&" months, "&If(Day(end_date)-Day(start_date)+1>=0,Day(end_date)-Day(start_date)+1,DateDiff(start_date,Date(Year(DateAdd(start_date,1,Months)),Month(DateAdd(start_date,1,Months)),1),Days)+Day(end_date))&" days including the end date."

     1.JPG2.JPG

    Best Regards,

    Bof

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 194 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 150

Last 30 days Overall leaderboard