cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gilmour
Helper IV
Helper IV

Can't get the difference in days between two date labels

Hi, 

 

I am trying to get a label to display the difference, in days, between the dates display in two other labels, like so:

 

Gilmour_0-1664722438559.png

 

but I keep getting a null value, regardless of what formula I use.

 

I've tried:

 

a. DateDiff(DateValue(Label12.Text),DateValue(Label12_1.Text),Days)

b. DateDiff(Label12.Text,Label12_1.Text,Days)

c. Label12.Text-Label12_1.Text

 

and I still get an empty box!

 

For the two labels containing dates, I've used the following formulas in the "Text" property of both:

DateValue(ThisItem.'MyDateValue'), and ThisItem.'MyDateValue' (the labels are both in a gallery that gets values from a SharePoint date columns). 

 

Just one of those mysterious things...

1 ACCEPTED SOLUTION

Accepted Solutions
Gilmour
Helper IV
Helper IV

Hi @timl , 

 

Yes, your code works IF the text label is inside the gallery. In my case, the date pickers (or labels) are inside and the label outside... I guess I might as well place the label inside the gallery and that will work.

 

Thank you for your response!  

View solution in original post

3 REPLIES 3
Gilmour
Helper IV
Helper IV

One important add... The issue seems to be due to the fact that the two date labels are in a gallery; if I recreate the scenario with two simple date pickers or labels that are not in a gallery, the formulas work. So the question is: how to get the datediff between two date fields in a gallery...

timl
Super User
Super User

@Gilmour 

Assuming that the source SharePoint columns are date columns, the following should work:

DateDiff(ThisItem.MyDateValue1,
         ThisItem.MyDateValue2,
         Days
)
Gilmour
Helper IV
Helper IV

Hi @timl , 

 

Yes, your code works IF the text label is inside the gallery. In my case, the date pickers (or labels) are inside and the label outside... I guess I might as well place the label inside the gallery and that will work.

 

Thank you for your response!  

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,873)