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 / Subtract two dates and...
Power Apps
Answered

Subtract two dates and bring the result in number for days

(0) ShareShare
ReportReport
Posted on by 2

working on power app for teams

 

In an edit form I have the following fields :

 

DateStart - user enters the start date

DateEnd - user enters the end date

TotalTakenDays - I want to keep disable the field to auto  calculate after the above entry - the difference of days in between both the dates -  Also to note that if the fields are blank , it will maintain 0

 

Reason of keeping 0 if any of the date field is blank, is that all the time dates are not available at the same moment, DateEnd info is received later.

please guide

 

                             

Categories:
I have the same question (0)
  • Verified answer
    v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @MIA27 

    You can try to use this code :

    If( DatePicker1.SelectedDate = Blank() || DatePicker2.SelectedDate = Blank() , 0 , DateDiff(DatePicker1.SelectedDate,DatePicker2.SelectedDate , TimeUnit.Days))
     
    The result is as follows:
    vyueyunmsft_0-1711000101934.png

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

     

  • MIA27 Profile Picture
    2 on at

    On what property of "TotalTakenDays", I should keep the code to obtain the result

     

  • Verified answer
    v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi,  @MIA27 

    In my understand , this is your "TotalTakenDays":

    vyueyunmsft_0-1711002603645.png

    In my side , i just put this code in a Label - Text :

     

    If( DatePicker1.SelectedDate = Blank() || DatePicker2.SelectedDate = Blank() , 0 , DateDiff(DatePicker1.SelectedDate,DatePicker2.SelectedDate , TimeUnit.Days))
     

    If I misunderstand what you mean, you can describe your needs and your expected outcomes in detail so that we can better help you. If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

  • MIA27 Profile Picture
    2 on at

    In my case it should be in Card Value properties, I will take a try.

    Thank you so much for your advise  and your time.

    Regards

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 914

#2
11manish Profile Picture

11manish 627

#3
Valantis Profile Picture

Valantis 598

Last 30 days Overall leaderboard