How to get current system time up to milliseconds

Use the Timer function to get the current amount of Seconds (including milliseconds) elapsed since 00:00:00. This sample code will get the time in format HH:MM:SS,mmss and report it to QTP results for the current step:

lSeconds=timer() ‘gets the current time in seconds, milliseconds

lHrs = Int(lSeconds / 3600)

lMinutes = (Int(lSeconds / 60)) – (lHrs * 60)

lSeconds = lSeconds – (lHrs * 3600) – (lMinutes*60)

TransTime = lHrs &":"&lMinutes&":"&lSeconds

msgbox TransTime

Reporter.ReportEvent 2, "Transaction time", TransTime ‘ sends the formatted time to the report

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s