Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
date difference
How can I have a macro figure the difference between two differnet times/dates. I wound really like to put a stop watch on some of my processes.

What format your times/dates have (SYSTEMTIME, FILETIME, DATE, from GetTickCount, from Date and Time functions, etc)? And what format should have the difference?

Probably GetTickCount will be best in this case. It returns number of milliseconds since Windows start. Example:
Copy      Help
int t1=GetTickCount
int t2=GetTickCount
out (t2-t1)/1000


Now let's use SYSTEMTIME.

Here is how to get time as SYSTEMTIME:
Copy      Help
SYSTEMTIME st; GetLocalTime(&st)

Here is function TimeDiff that returns difference between two times as number of seconds:
Copy      Help
function% SYSTEMTIME*time1 SYSTEMTIME*time2

;Returns difference between two times as number of seconds.
;If time1 is more than time2, return value is positive;
;if time1 is less than time2, return value is negative.
;time1 and time2 are pointers to variables of type SYSTEMTIME.
;To get current time, use function GetLocalTime.

;SYSTEMTIME before2seconds now
;GetLocalTime &before2seconds
;wait 2
;GetLocalTime &now
;out TimeDiff(&now &before2seconds)

type FTLONG FILETIME'ft [0]%l
FTLONG ft1 ft2
if(!SystemTimeToFileTime(time1 &ft1.ft) or !SystemTimeToFileTime(time2 &ft2.ft)) end "invalid argument"

ret (ft1.l/10000000)-(ft2.l/10000000)
Thanks for the reply...
Those codes will work great!!!!!!!
They were exactly what I was needing...

Forum Jump:

Users browsing this thread: 1 Guest(s)