web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Recording multiple tim...
Power Apps
Answered

Recording multiple time stamp with one button

(0) ShareShare
ReportReport
Posted on by 10

I'm trying to create a button that records different timestamps every time the user presses it(also display what they recorded right below the button), and it'll be recorded in a collection as pairs of start and end time stamps. However, my code only records the same time stamp in the collection for start and end when I press the button.

 

Here's what I have right now:

 

roy1218_1-1652891902769.png

roy1218_2-1652891950607.png

Instead, it should look more like this as an example:

roy1218_3-1652892004590.png

Please let me know how I can correct my code to achieve this results.

 

 

 

 

 

 

 

Categories:
I have the same question (0)
  • efroseroc Profile Picture
    152 on at

    Hi, I don't know if I understand correctly, but have you tried to put : "hh:mm:ss" only?

  • roy1218 Profile Picture
    10 on at

    yes, and it still records the same time stamps for start and end column in the collection 

  • One Profile Picture
    416 on at

    Hi @roy1218,

    If I am understanding the situation correctly, you will need two separate buttons for start and stop if you want to update the record with a stop time. Because there is no distinction between a first and second button click, it will fill the start and stop times with the same value. 

    Otherwise if you were looking to just get the time then @efroseroc was correct, you would adjust your code to the following:

    Set(var_start, Text(Now(),"hh:mm:ss")); Set(var_end,Text(Now(),"hh:mm:ss")); Collect(col_data,{start:var_start, end:var_end, rownumber:Label3_1.Text});

     

    ------------------------------------------------------------------------------------------------------------------------------
    Please click "Accept as Solution" if this post answered your question so that it is helpful for people having similar questions. If you found this post helpful smack that Thumbs up button! Thanks! 

  • roy1218 Profile Picture
    10 on at

    Thank you for your response. If I can simplify the situation to only the start time stamp, how can I average the differences of all the start time stamps recorded?

  • efroseroc Profile Picture
    152 on at

    ok I get it, set a Variable that counts from 0 to 1. and Set a variable that counts the IDs of each row.

    OnStart Set(var;0)

             Set(var2;0)

    If(var=0;Concurrent(Set(var;1);Set( Var_Start; Text(Now();"hh:mm:ss"))))

    If var =1; Concurrent(Set(var;0);Set( Var_End; Text(Now();"hh:mm:ss");Set(var2;var2+1)))

     

    Then you would need another variable that counts each row ID . 

    But I'd prefer to just add another button for the end time and put the variable there.

    I hope it helps.

  • efroseroc Profile Picture
    152 on at

    In this case add a variable that adds up the times the button was pressed, then use the variable to divide another variable that sums all times.

    But you would have to record only the seconds or minutes.. And you cannot use Text()

  • v-jefferni Profile Picture
    on at

    Hi @roy1218 ,

     

    Based on your requirement, I made a demo for your reference:

    RecordTime.gif

     

    OnSelect of Record button:

    UpdateContext(
     {
     varTime: Text(
     Now(),
     DateTimeFormat.ShortDateTime
     ),
     clickNo: clickNo + 1
     }
    );
    If(
     Mod(
     clickNo,
     2
     ) = 0,
     Collect(
     colTimes,
     {
     start: varTime,
     end: "",
     rownumber: RoundUp(
     clickNo / 2,
     0
     )
     }
     ),
     Patch(
     colTimes,
     Last(colTimes),
     {end: varTime}
     )
    )

     

    OnSelect of Clear button:

    Clear(colTimes);UpdateContext({varTime:Blank(),clickNo:1})

     

    Hope this helps.

     

    Best regards, 

  • roy1218 Profile Picture
    10 on at

    Thank you so much for your response. There seems to one part that didn't solve the issue for me. 

    roy1218_0-1653415293224.png

    When I clicked the "Record" button three times, I was hoping to have three rows of data because the "end" timestamp of the first row should automatically become the "start" timestamp of the second row. Just like this picture below:

    roy1218_1-1653415423003.png

    Once the "start" timestamp is recorded in the first row, the "end" timestamp of the current row and "start" timestamp of the following row should be the same as I keep pressing the "Record" button. Please let me know if this makes sense. Thank you!!

  • Verified answer
    v-jefferni Profile Picture
    on at

    Hi @roy1218 ,

     

    Formulas for this scenario will be much easier.

     

    OnSelect of the record button:

    UpdateContext(
     {
     varTime: Text(
     Now(),
     DateTimeFormat.ShortDateTime
     ),
     clickNo: clickNo + 1
     }
    );
    Collect(
     colTimes,
     {
     start: varTime,
     end: "",
     rownumber: clickNo
     }
    );
    Patch(
     colTimes,
     LookUp(
     colTimes,
     rownumber = clickNo - 1
     ),
     {end: varTime}
    )

     

    OnSelect of clear button:

    Clear(colTimes);
    UpdateContext(
     {
     varTime: Blank(),
     clickNo: 0
     }
    )

     

    Best regards,

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard