Forum Discussion

Madhi's avatar
Madhi
Contributor
15 years ago

Stop Watch string object

I get the time in milliseconds from -

 set StopWatchObj1 = histuils.stopwatch

stopwatchobj1.tostring

I need to store this in a excel sheet so I use the function aqtime.writetotextfile to write it in a .csv file which I can open in excel. 

The resut of stopwatchobj1.tostring in the .csv file when I open as text file shows the right string "0:00:02:690".

When I open the same in excel, I see the result as 00:00:2



Is there a way I can get the same format in excel??

6 Replies

  • ChrisH's avatar
    ChrisH
    Occasional Contributor
    If you're using that Excel sheet just to manually view the values which
    TC has output, then you can change the cell formatting in Excel by going
    to Format -> Format Cells... (keyboard shortcut "Ctrl + 1").  On the "Number" tab choose the "Custom" option, and then on the right in the "Type" textbox enter:



      hh:mm:ss.000



    Then click OK and it should appear correctly on the spreadsheet.
  • Yeah.. i do that.. but is there a way the enduser can view the same format without doing any workaround..

    I have to give my scripts to my client.. when they view the result sheet they should be able to get it.



    Thanks for your replly...
  • In that case you'll have to modify the value before it gets written to the csv file. There are two options:

    1) Preceed the value with a single quote to force it to be interpreted as a string, as follows:

    '0:00:02:690

    2) Change the last colon to a decimal point and it should be interpreted as a time, as follows:

    0:00:02.690


  • Hi Madhi,


    Please note that this forum is actually for AutomatedQA TestComplete functionality questions, not for questions on Microsoft Excel.

  • I understand this forum is not for excel.  My question is totally related to the output from HISUtils stopwatch object



    I tried the aqdatetime.Timeinterval to fnd out the difference between the two results i get from stopwatch.  Looks like i need to have date format as well to use the timeinterval method.  Do you have any suggestion to calculate the difference


    The output from stopwatch object.tostring is in the format hh:mm:ss.000

  • ChrisH's avatar
    ChrisH
    Occasional Contributor
    You can get the elapsed milliseconds from the StopWatch.Split() and StopWatch.Stop() methods.





    JScript:



    function StopWatchTest()

    {

      var stopWatch = HISUtils.StopWatch;

     

      stopWatch.Start();

     

      Sleep(1500);

     

      var startTime = stopWatch.Split();

     

      Sleep(2000);

     

      var endTime = stopWatch.Stop();

     

      Log.Message("Start time: " + startTime + "ms");

      Log.Message("End time: " + endTime + "ms");

      Log.Message("Duration: " + (endTime - startTime) + "ms");

    }