Link to home
Start Free TrialLog in
Avatar of raslan
raslan

asked on

how to use time and date

how to insert  TIME AND DATE  in a form and use it in our application(example i need to run a function at 3:00 AM  on monday )
please i need the full procedure + an example
Avatar of raslan
raslan

ASKER

Edited text of question
Put a timer in the form and check the time at regular interval. Is this what you want?
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

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
Here is the full procedure.......

procedure TForm1.Timer1Timer(Sender: TObject);
var
  MyTime : TDateTime;
begin
  MyTime := StrToTime('3:00am');
  if (Time >= MyTime) and (DayOfWeek(Date) = 2) then//Sunday = 1, Monday = 2
  begin
    timer1.enabled := false;
    ShowMessage('Hello there, it''s 3:00am');
  end;
end;

WaitForSingleObject is *theorically* better :

Case WaitForSingleObject(Application.Handle, (DateTimeReActivation - Now) * 86400 * 1000) Of
//WAIT_ABANDONED:
//WAIT_OBJECT_0      :
WAIT_TIMEOUT:
  {Action}
End;

JDB
Hello???

Are oyu going to accept or reject my answer. Please do one of the two. Thanks

Regards,
Viktor Ivanov