Subtracting one time stamp from another
Moderators: Dorian (MJT support), JRL
Subtracting one time stamp from another
Is it possible to subtract one time stamp from another?
For example, I am interested in finding the difference between 07:06:44 and 07:00:00.
Thanks much,
Rory
For example, I am interested in finding the difference between 07:06:44 and 07:00:00.
Thanks much,
Rory
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
For measuring elapsed time I always use VBScript's Timer function which returns seconds since midnight. Therefore easy to subtract start from finish and get elapsed seconds. Lots of examples here - search site for Timer.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
I have not used Timer, but seem to recall that there may be a problem if using times that go past midnight, using different dates. That is why I end up using DateDiff instead. Multiple dates are taken care of automatically.
To get seconds, use "s":
But this will be total seconds. You will need to take the remainder of seconds to use with minutes, like this:
To get seconds, use "s":
Code: Select all
VBEval>DateDiff("s","%timStart%","%timStop%"),numSeconds
Code: Select all
VBEval>DateDiff("n","%timStart%","%timStop%"),numMinutes
VBEval>DateDiff("s","%timStart%","%timStop%"),numSeconds
\\ Help file does not have a sample of using MOD operator. May not work.
Let>numSeconds={Mod(%NumSeconds%,60)}
Let>ElapsedTime=%numMinutes%:%numSeconds%
Last edited by Bob Hansen on Tue Dec 09, 2008 10:57 pm, edited 1 time in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Glad it works Rory.
And thanks for the syntax Me_again. As I noted in my script, the syntax for MOD was unknown to me.
Marcus, I think we need to have sample with syntax format added to Help file with Arithmetic Operators. Also need example for DIV? Is it the same as MOD?
And thanks for the syntax Me_again. As I noted in my script, the syntax for MOD was unknown to me.
Marcus, I think we need to have sample with syntax format added to Help file with Arithmetic Operators. Also need example for DIV? Is it the same as MOD?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Hmm, I have come to accept that the syntax is implied. MOD and DIV are both arithmetic OPERATORS, not functions. No different from +. -, -, / symbols. They are used the same way, value1 operator value2.
I am used to other languages where MOD is more of a function like INT, ABS, ROUND, etc.
I am used to other languages where MOD is more of a function like INT, ABS, ROUND, etc.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I was going to say the same thing. They are documented in the help file under "Complex Expressions" -> "Arithmetic Operators" along with the easy ones: +, - etcBob Hansen wrote:Hmm, I have come to accept that the syntax is implied. MOD and DIV are both arithmetic OPERATORS, not functions. No different from +. -, -, / symbols. They are used the same way, value1 operator value2.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?