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 / Time spent (Timer roun...
Power Apps
Answered

Time spent (Timer roundup minutes)

(0) ShareShare
ReportReport
Posted on by 2,567

Hi

 

I'm trying to create the following.
- Timer starts when pressed.

- Timer Ends, roundup to minutes always and patch SharePoint column (Column named "TimeSpent").

- If timer starts again later on the same item I will take the current minutes saved in the column "TimeSpent" and add the new minutes and then patch.

 

Now first issue is a normal timer looks like it stops the time if you minimize the window. This was solved as following.

 

- StartButton

Set(StartTime, Now());
UpdateContext({StartTimer:true})

- Timer

OnTimerStart:
Set(Now, Now())

-TimerLabel Showing Time

Text(Time(0, 0, DateDiff(StartTime,Now,Seconds)), "[$-en-US]hh:mm:ss")

 The above will keep the time running even if you minimize the window and do something else.

 

Now what I want is to take the data from the TimerLabel and RoundUp to only minutes. (This is what i have issue with, dont know how to do this correctly)

 

Last step is to patch the SharePoint column with the minutes. This part is half done as i can patch the column but i cannot get only minutes and my other issue is if the item already have data in the column, for example the item has 55minutes stored, then i want to take the 55 and add the new minutes i just collected and patch it.

 

 

Categories:
  • v-albai-msft Profile Picture
    Microsoft Employee on at

    Hi @JimmyWork ,

    Based on you description, I do a simple test for your reference.

    I assume that: You have two button, one button for creating new item, the other button for updating TimeSpent value.

    So I create a list with a Number column called “TimeSpent”:

    v-albai-msft_0-1613558136218.png

    Go to my app, set OnSelect property of Patch button to(this will create a new list item):

    Patch(list2,Defaults(list2),{Title:DataCardValue1.Text,TimeSpent:RoundUp(Timer2.Value/60000,0)})

    Set OnSelect property of Update button to(this will update the item whose Title is match the entered value):

    Set(varItem,LookUp(list2,Title=DataCardValue1.Text));Patch(list2,varItem,{TimeSpent:varItem.TimeSpent+RoundUp(Timer2.Value/60000,0)})

    v-albai-msft_1-1613558136223.png

    You can also add some condition then add above two formula into one button, for example, if “DataCardValue1.Text in list2.Title”, lookup this item by Title, then update its value; if not, create a new list item.

    Best Regards,

    Allen

  • JimmyW Profile Picture
    2,567 on at

    @v-albai-msft Thank you for answering but i cannot use the Timer value as the timer just repeats every second and on timer start i have Set(Now, Now()) then i use DateDiff to get the actual time spent, i do this because if you use a normal timer and minimize the browser the timer stops.

  • v-albai-msft Profile Picture
    Microsoft Employee on at

    Hi @JimmyWork ,

    So try to use below formula for Patch button:

    Patch(list2,Defaults(list2),{Title:DataCardValue1.Text,TimeSpent:RoundUp(DateDiff(Now,Now(),Minutes),0)})

    And below formula for Update button:

    Set(varItem,LookUp(list2,Title=DataCardValue1.Text));Patch(list2,varItem,{TimeSpent:varItem.TimeSpent+RoundUp(DateDiff(Now,Now(),Minutes),0)})

    Best Regards,

    Allen

  • JimmyW Profile Picture
    2,567 on at

    @v-albai-msft Thank you again

    I dont know if i understand the RoundUp function wrong, as I have everything working but in my mind when the timer starts and it has gone 20sec then it should round up to 1min, and if the time has counted 1min, 9sec it should round up to 2min. It does not seem to do this, at least not if i create a label and have RoundUp(DateDiff(StartTime,Now,Minutes),0)

    When i stop the timer it does not roundup

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

    Hi @JimmyWork ,

    Based on my test, I add more label to display the value of “StartTime”, “Now” and “DateDiff” , and find that the DateDiff returns as 0:

    v-albai-msft_0-1613963731079.png

    So this is the issue. When DateDiff() uses two times that only has different seconds(with same minutes and hours), the result will return 0. This formula will work when the minutes(or hours) of the two times are different:

    v-albai-msft_1-1613963731081.png

    Per my test, you can use below formula:

    RoundUp(DateDiff(StartTime,Now,Seconds)/60,0)

    v-albai-msft_2-1613963731084.png

     

    v-albai-msft_3-1613963731085.png

    Best Regards,

    Allen

  • JimmyW Profile Picture
    2,567 on at

    @v-albai-msft Thank you so much for the 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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard