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 / Calculate datediff in ...
Power Apps
Answered

Calculate datediff in days between two date fields in a form

(0) ShareShare
ReportReport
Posted on by 159

I have a Form with two dates fields, named From_picker and TO_picker. Also i create a button and a label outside the form. I test the formula bellow, where i create a variable that i assigned to a label to show the result. Unfortunately nothing is calculated and i don't know why.

If i used two fields that are not part of the form it's working...

 

Set(varDateDiff,(DateDiff(From_picker.SelectedDate,TO_picker.SelectedDate,Days)))

Categories:
I have the same question (0)
  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @ciprianpopovici 

    Check this will help you https://youtu.be/FbdGLVCvgRo 

  • ciprianpopovici Profile Picture
    159 on at

    Hello, thank you for the tip, o  look at the video , but cannot find a solution. All the examples are for "simple" fields, that are not part of a form.  Like i say it's working when the fields are not part of the form. But if my date fields are part of a form and , i want to use that value outside the form .

     

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @ciprianpopovici,

    Do you meant that you have a button and a Label out of the form and they could not display the variable related the date differ?

    Could you please share a bit more about your scenario?

     

    I have a test and the situation is confirmed on my side that the Label out of the form display the variable as expected.

    vqiaqimsft_0-1639637969464.png

    Try set the Label Text directly as below:

    DateDiff(From_picker.SelectedDate,TO_picker.SelectedDate,Days)
  • ciprianpopovici Profile Picture
    159 on at

    Hello,

    I try any version but with no luck. I create another screen , another form but still not show anything.

    For testing , i add a form to a screen and outside the form i create a button  and a label. I used both variants , with formula on label and with formula o button click.

     

    i attached a screenshot, maybe someone can se why there is no value displayed.

     

    foto1.PNG
  • ciprianpopovici Profile Picture
    159 on at

    I attached a few screenshots with the button code and variable. The form is related to a SharePoint list.

    Thank you

     

    foto3.PNG
    foto2.PNG
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @ciprianpopovici,

    That's so weird.😂

    vqiaqimsft_0-1639645075559.png

    Would you mind creating a new form to restore it?

    Or I think you should close the Power Apps app and try it later, sometimes that's how magic works.😅

     

  • Verified answer
    AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Is the Formmode New or edit? if not try it as new that would clarify if issues exist with its Item. This can be an issue sometimes. If this works then this issue is usually makes the form not show values but show them in some places. It can be caused when there is no item or a blank item on edit form. Or if the form has not been ResetForm() onsuccess.

  • ciprianpopovici Profile Picture
    159 on at

    Hello, i try your recommendations and it's working.

    Thank you very much. Appreciate your help.

     

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard