Forum Discussion

nedbacan's avatar
Frequent Contributor
5 years ago

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...
  • Wamboo's avatar
    5 years ago

    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!");
  • Wamboo's avatar
    5 years ago

    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!