Ask a Question

TestComplete function to capture system clock of computer

Frequent Contributor

TestComplete function to capture system clock of computer

Hello, can someone tell or show me how can I capture the system clock time/date and use it to compare the time/date to an object property checkpoint value , and report the result to a log, pass if it matched.


Also if it can check the format if is correct as well but this can be a seperate check.


I am using Keyword scripting and if I can add it to a script routine it will be nice.  Thank you !!

Community Hero

Hi Ned


"capture the system clock time/date"

Use the aqDateTime.Today method to get the current date.

To obtain both the current date and time, use the Now method

To obtain only the current time, use the Time method.


Doc link:


"to compare the time/date to an object"

The aqDateTime.Compare method compares two Date/Time values.


"I am using Keyword scripting and if I can add it to a script routine it will be nice."

Check my tutorial on this topic:


"How to check results"

Use -> aqDateTime.Compare

Result Value

An integer number that indicates the comparison result. The possible values are:

-1 Date1 is earlier than Date2
0 Date1 is equal to Date2
1 Date1 is later than Date2


Use these values inside if condition to obtain results.


let result = aqDateTime.Compare(Date1, Date2);

if(result === 1) {
  Log.Checkpoint("It's 1!");
Frequent Contributor

Appreciate your help but I am new to scripting. 


Please if you can elaborate how will I get the time displayed as a label on the screen (see attachment) and compare it to the system clock using the aqDateTime.Compare method.   I added a screen shot of the object property of the label, which name will work to compare with the system time?


I need to add both times as variables? 


Anyhow a small demonstration would be great as you did in the tutorial below ..!!  


Thank you very very much. 😃

SmartBear Alumni (Retired)

Thank you for your help Wamboo!


Hi @nedbacan, were you able to solve this? Please share what your current situation is. 

Sonya Mihaljova
Community and Education Specialist

Hi nedbacan,

1) You can try to access this property from the first screenshot using the file object.innerText save it in the variable

2) get the current time using the native TestComplete built in class. You have doc in my first entry

3) parse1 and 2 to the appropriate date format

4) use the native TestComplete solution to compare values.

I hope this will help you!


Showing results for 
Search instead for 
Did you mean: