Link to home
Start Free TrialLog in
Avatar of aqm
aqm

asked on

Simple Question about Time

Hi,
I'm new in Delphi...

How I can take the time to do a Query in miliseconds ?

Thanks in advance !
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rwilson032697
rwilson032697

To calculate the number of milliseconds do this (assuming you use the Delphi Time function):

var
 TimeAfter, TimeBefore : TDateTime;

.
TimeBefore := Time;
// Do your stuff here
TimeAfter := Time;

// How many milliseconds?
x := (TimeAfter - TimeBefore) * (86400 * 1000);  // 86400 seconds/day...


Cheers,

Raymond.

this is the statment to get millisecons from system time

var
  starttime,finishtime, actualresponse : TDateTime;
  Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
  starttime := Time;
  DecodeTime(starttime, Hour, Min, Sec, MSec);
  { display millisecons }
  label1.caption := inttostr(msec);

  Finishtime := Time;
  DecodeTime(finishtime, Hour, Min, Sec, MSec);
  { display millisecons }
  label2.caption := inttostr(msec);
 
{ you can also do this statment }
  actualresponse := finishtime - starttime;
  DecodeTime(actualresponse, Hour, Min, Sec, MSec);
  { display millisecons }
  label3.caption := inttostr(msec);

end;