cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
momolopu
Helper I
Helper I

Example of saving seconds in a variable

Hello, can someone give me an example of how to save in a variable the real seconds that are passing please, I need it for a project.

 

Thank you very much for your time.

10 REPLIES 10
VJR
Super User
Super User

@momolopu 

Are you saying you need the seconds from the current time?

 

VJR_0-1659604298796.png

 

momolopu
Helper I
Helper I

But it would not be to show only the seconds of the current date. It would be a variable that would start from 0 and would increase by 1 for each second that passes.

 

Thank you very much for your time, you help me a lot.

Not fully sure what you are trying to achieve, but you can use Wait action to wait for 1 second and then increment variable by 1

momolopu
Helper I
Helper I

Yes, if I do that and put an execution delay of 1 ms and put it in a loop I increase +1 to the variable every second.

But is there any way to make it do that without getting stuck in a loop?

That is to say that it goes counting the seconds while it continues doing other things?

I don't know if I have explained myself a little strange hehe

ryule
Skilled Sharer
Skilled Sharer

I think the only way to achieve this would be to set a variable for start_time in the spot in the bot where you want it to start, and then set another variable for end_time, and then compare

LogicSmith
Resolver I
Resolver I

Yes, Ryule is right. Assuming you want the answer to "how long did this take", the only way is to grab the time into a start time variable, then when you're done, grab the time into an end time variable, subtract the start from the end, and you can do that in seconds, minutes, whatever. I use this exact method to time how long some flows take to write to a log file.

VJR
Super User
Super User

@momolopu, looks like you want to have a continuous running time that will keep on ticking every second WHILE the other PAD actions keep running.

Something like a DoEvents in VBA...which will continue the events while the program is running.

Doesn't seem to have a similar feature in PAD...the execution stops until that action is completed. You can play around and see if you can achieve the same.

momolopu
Helper I
Helper I

@ryule @LogicSmith If that would be great for me, would you be so kind to give me an example, I am quite new to this program. Thank you very much.

LogicSmith
Resolver I
Resolver I

If you want to know how long something takes, I can provide code for that (3 actions). If you want something to happen every second, Power Automate is not the tool for that. Sorry.

 

ryule_0-1659991810960.png

 

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Top Solution Authors
Top Kudoed Authors
Users online (3,111)