# Thread: Finding difference between two times stamps

1. ## Finding difference between two times stamps

Hi,

I have to calculate the difference between the two times
Ex: The time difference of both the variables.
starttime = 10:20:40;
endtime = 15:10:30

now i need to find out the difference time between both the variables.

Any thoughts would be appreciated.

2. ## Re: Finding difference between two times stamps

Write them out to XL which has the calculation in it and read back the answer

3. ## Re: Finding difference between two times stamps

</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">static starttimeArr[], endtimeArr[];
split(starttime, starttimeArr, &quot;:&quot;
split(endtime, endtimeArr, &quot;:&quot;

starttimeSec = starttimeArr[3] + (starttimeArr[2]*60) + (starttimeArr[1]*60*60);
endtimeSec = endtimeArr[3] + (endtimeArr[2]*60) + (endtimeArr[1]*60*60);

difftimeSec = endtimeSec-starttimeSec;
difftimeH = int(difftimeSec/(60*60));
difftimeM = int((difftimeSec-(difftimeH*60*60))/60);
difftimeS = difftimeSec % 60;

difftime = difftimeH &amp; &quot;:&quot; &amp; ((difftimeM&lt;10) ? &quot;0&quot; : &quot;&quot &amp; difftimeM &amp; &quot;:&quot; &amp; ((difftimeS&lt;10) ? &quot;0&quot; : &quot;&quot &amp; difftimeS ;</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Just out of my head - sorry if it contains a mistake...

Regards,
Juergen

4. ## Re: Finding difference between two times stamps

Juergen Thanks a lot.

The code works excellent...!! [img]images/icons/smile.gif[/img]

5. ## Re: Finding difference between two times stamps

Why not use transaction markers in your script and have WinRunner calculate this for you atuomatically?

6. ## Re: Finding difference between two times stamps

good idea, but does not work in my case.

As I am reading the data sheet, which is output of another script(consolidated result's sheet), which will have the timings of each operation performed by the script.

The analyzer script I am calculating the time taken to execute the particular operation. So that I can say that the particular operation has taken so and so time.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:14 AM.