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 / Count duration with Da...
Power Apps
Answered

Count duration with DateDiff and Cds / Dataverse

(0) ShareShare
ReportReport
Posted on by

Hi, I am new Power Apps user. I need help to fix this.

 

I a create powerapps with cds/dataverse for employee check in and check out. in button check out, i want count duration with datediff. but, i get problem with "Invalid argument type" in button check out. My code in check out like this.

 

Patch(
 'Time Entries',
 LookUp(
 'Time Entries',
 'Time Entries'.Start = GalleryTimeEntries.Selected
 ),
 {
 'Bookable Resource': GalleryResource.Selected,
 'Work Order Service Task': GalleryServices.Selected,
 End : Now(),
 Duration: DateDiff(
 LookUp(
 'Time Entries',
 'Time Entries'.Start = GalleryTimeEntries.Selected
 ).Start,
 Now(),
 Minutes
 )
 }
 )

 

Screenshot (4).pngScreenshot (6).png

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,426 Most Valuable Professional on at

    Hi @BayuChoirul ,

    The fundamental problem is that .Selected returns a record and you are trying to match it with a Value. Without seeing your model, data and required outcome, this may not be correct, but the syntax maybe should be something like this. Note you will need to include the field that is unique to the record (to identify which record to Patch)

    With(
     {wTime:GalleryTimeEntries.Selected},
     Patch(
     'Time Entries',
     {IDField:wTime.IDField},
     {
     'Bookable Resource': GalleryResource.Selected,
     'Work Order Service Task': GalleryServices.Selected,
     End : Now(),
     Duration: 
     DateDiff(
     wTime.Start,
     Now(),
     Minutes
     )
     }
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • BayuChoirul Profile Picture
    on at

    thanks for your help. may i ask a questions again. Formula has been solve, but i get new problem. that is "msdyn_start : field mysdn_start required". location in button check out

  • WarrenBelz Profile Picture
    154,426 Most Valuable Professional on at

    Hi @BayuChoirul ,

    This is a bit of a guess, but does this work

    With(
     {wTime:GalleryTimeEntries.Selected},
     Patch(
     'Time Entries',
     {IDField:wTime.IDField},
     {
     'Bookable Resource': GalleryResource.Selected,
     'Work Order Service Task': GalleryServices.Selected,
     Start: wTime.Start,
     End : Now(),
     Duration: 
     DateDiff(
     wTime.Start,
     Now(),
     Minutes
     )
     }
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • BayuChoirul Profile Picture
    on at

    thanks for your help. but, formula still not counting duration.

  • WarrenBelz Profile Picture
    154,426 Most Valuable Professional on at

    @BayuChoirul ,

    If you put this in a label, do you see the Start value?

    GalleryTimeEntries.Selected.Start

    If not you need to find out where this value is so the calculation can be done.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • BayuChoirul Profile Picture
    on at

    thank you warren, duration can be calculated

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
wolenberg_ Profile Picture

wolenberg_ 119 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 107 Most Valuable Professional

#3
Haque Profile Picture

Haque 103

Last 30 days Overall leaderboard