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 / Collection: Outcome va...
Power Apps
Answered

Collection: Outcome values 0

(0) ShareShare
ReportReport
Posted on by 69

I want to execute a DateDiff function in a collection. The calculation is also successful, but I don't succeed in displaying it correctly in a DataTable or Gallery. Although the correct value (e.g. 5) is displayed in the code, a 0 is displayed in the gallery.

 

Patch(
 CollectionName;
 Last(CollectionName);
 {
 Hours: DateDiff(
 Last(CollectionName).Start;
 Last(CollectionName).End;
 Hours
 )
 }
)

In the meantime I have tried out some possibilities and even deleted the collection and completely rebuilt it, but I just don't know where the problem is. Maybe someone has an idea and can help me.

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @brimstone 

    Can you please post some screenshots of the successful outcome (e.g. showing 5) and the unsuccessful outcome (e.g. showing 0)?  This will help my understanding of your issue.

     

    It would also be helpful to see your inputs (e.g. last row of collection in the viewer)

  • brimstone Profile Picture
    69 on at

    @mdevaney 

    I have set End to be 5 hours in the future (and thus the result of the DateDiff function is 5). In the Gallery the result should be in the column "Stunden", where currently 0 is displayed.


     


  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @brimstone 

    Very nice screenshot, thank you! 

     

    Your goal is to calculate the hours between ArbeitsBeginn and ArbeitsEnde.  The problem is you are changing the value of ArbeitsEnde in the same PATCH as when StundenNetto is calculated.  ArbietsEnds does not update until the entire PATCH is completed.  Because of this StundenNetto will be the result of DateDiff(18.10.2019 13:39,18.10.2019 13:39,Hours)

     

    The solution is to PATCH twice instead: first update ArbeitsEnde and then update StundenNetto 

     

    Patch(
     ArbeitszeitErfassung;
     Last(ArbeitszeitErfassung);
     {ArbeitsEnde: DateAdd(Now();5;Hours)}
    );
    Patch(
     ArbeitszeitErfassung;
     Last(ArbeitszeitErfassung);
     {
     StundenNetto: DateDiff(
     Last(ArbeitszeitErfassung).ArbeitsBeginn;
     Last(ArbeitszeitErfassung).ArbeitsEnde;
     Hours
     )
     }
    );

     

    Please make sure to double-check my snytax for the placement of brackets and semi-colons Cat Wink

     

    ---
    Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

  • brimstone Profile Picture
    69 on at

     @mdevaney 

    This works perfectly, thank you very much!

  • mdevaney Profile Picture
    29,991 Moderator on at

    @brimstone 

    No problem at all.  By the way, what language is that collection using?  I only speak English so I was not able to understand it fully.

  • brimstone Profile Picture
    69 on at

    @mdevaney 

     

    It's german 🙂 

  • mdevaney Profile Picture
    29,991 Moderator on at

    @brimstone 

    I was hoping it was German!  My ancestry is part German and I think it would be pretty neat to learn the language some day.

  • brimstone Profile Picture
    69 on at

    @mdevaney 

    I can fully understand your drive to learn German because of that.

    I get to hear more often that the language isn't very easy to learn, but I wish you a lot of fun learning it!

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 545 Most Valuable Professional

#2
Haque Profile Picture

Haque 314

#3
Kalathiya Profile Picture

Kalathiya 234 Super User 2026 Season 1

Last 30 days Overall leaderboard