Forum Discussion

Rammherz's avatar
Rammherz
Occasional Contributor
6 years ago
Solved

Problem with finding TimeInterval when start time and finish time are in different dates

Hi all!

I use the following code to measure time needed for test execution

nTestStartTime = aqDateTime.Time();
nTestExecutionTime = aqConvert.DateTimeToFormatStr(aqDateTime.TimeInterval(nTestStartTime, aqDateTime.Time()), "%#H:%M:%S");

I have a problem with case when start time and finish time are in different dates. I.e:

Test start: 2018-05-17   23:54:58
Test finish: 2018-05-18   00:01:37

 

Expected result: 00:06:39
Actual result: 23:53:21

 

Please help me to correct code to get actual result.

 

Thanks!

  • Using aqDateTime.Time() simply records the time of day.  So, if the time spans more than 24 hours, this isn't going to account for the span in days.  Replace aqDateTime.Time() with aqDateTime.Now() and try again.

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Using aqDateTime.Time() simply records the time of day.  So, if the time spans more than 24 hours, this isn't going to account for the span in days.  Replace aqDateTime.Time() with aqDateTime.Now() and try again.