Home > Back-end >  How do the deiphi at 9 o 'clock in the morning to execute a program at 3 thank you
How do the deiphi at 9 o 'clock in the morning to execute a program at 3 thank you

Time:10-27

Can set the TIMER control interval is the interval is set to 300000 for 5 minutes, but can not specify the specific time, do I want to write a program to the customer then he need only after the operation was hanging on the server at 9 o 'clock to 3 o 'clock every day fixed every 5 minutes to perform a inserted into the database program, how to realize the thank you, very urgent

CodePudding user response:

Top off your post, thank you for your help!

CodePudding user response:

After the TIMER Settings, can timing judgment 09:00 & lt; The current time & lt; 15. 00, to perform the following actions,

CodePudding user response:

Take a time every 5 minutes, if the time between 9-3 points, will perform operations

CodePudding user response:

The interval or the default of 1000

Timer1Timer events:
Var
D: TDateTime;
H, T: string;
The begin
D:=Now;
H:=Formatdatetime (HH, D);
T:=Formatdatetime (HHNN, D);

If (H> '9') and (H<'15') and (StrToInt (T) Mod 5=0) then
The begin
Timer1. Enabled:=False;
//code execution, the execution after setting Enabled again=True;
end;
end;

CodePudding user response:

Application time for current system time when
Var
Cur_time: Tdatetime;
Tem_time: Tdatetime;
The begin
If (formatdatetime (' mm: dd: ss ', now) & gt; '09:00:00) and
(formatdatetime (' mm: dd: ss ', now) & lt; '15:00:00) then
The begin
Cur_time:=now;
If datediff (s, cur_time temp_date)=5 then
The begin
Temp_date=cur_time;
InsertdatatoDB ();
end;
end;
end;

CodePudding user response:

Use DateDiff () function,

Description
Returns the time interval between two dates,
Syntax
DateDiff (interval, date1 and date2 [, firstdayofweek [, firstweekofyear]])
DateDiff function grammar has the following parameters:

Parameter description
Interval choice, string expression, said is used to calculate the time interval between date1 and date2, about values, please refer to the "Settings" section,
Date1 and date2 choice, date expression, is used to calculate the two dates,
Firstdayofweek optional, specify the first day of the week's constant, if not specified, the default for Sunday, about values, please refer to the "Settings" section,
Firstweekofyear optional, constant specified in the first week of the year, if not specified, the default for January 1 week, about the number, please refer to the "Settings" section,


Set the
The interval parameter can have the following values:
Set the description
Yyyy years

q quarterM on
Y a year of days
D day
W week days
Ww week
H hours
M minutes
S second

CodePudding user response:

Write a program that insert,
With plans to put the program task,

CodePudding user response:

Ask why the 4th floor TIME> 9 when less than 15 Timer1. Enabled:=False after and then execute the code and then Timer1. Enabled:=true,,,

CodePudding user response:

The
reference 7 floor response:
write an insertion process,
With plans to put the program task,



Obviously using plan task well

CodePudding user response:

Under this program, please change to 9 o 'clock in the morning until half past eleven, 1 PM to 3 PM insert how to modify, thank you,

CodePudding user response:

Is the right thing by plan task scheduling exe
Otherwise, always running exe, and then through the timer per second to determine the current time, is the appointed time, to implement the code function

CodePudding user response:

Open EXE fall doesn't matter, put it on the server, best can write code, or one thousand program and in other places,

CodePudding user response:

The
references to the eighth floor response:
asked why the 4th floor in TIME> 9 when less than 15 Timer1. Enabled:=False after and then execute the code and then Timer1. Enabled:=true,,,


One thousand do not finish within the interval?

CodePudding user response:

In addition to the planning task,
CreateWaitableTimer/SetWaitableTimer to complete the timing routines for a long period of time.
The next time interval was calculated by the current time (time) and SetWaitableTimer, and then wait for the signal, the signal, the time for it. The error less than 1 second
Or directly in SetWaitableTimer set the absolute time of the next, and then is waiting for the signal.
And it is said that can let the computer recovery standby (this I didn't try... )

CodePudding user response:

Ask: when standby no program is running?

CodePudding user response:

refer to the 13th floor response:
refer to the eighth floor response:
Ask why the 4th floor TIME> 9 when less than 15 Timer1. Enabled:=False after and then execute the code and then Timer1. Enabled:=true,,,


One thousand do not finish within the interval?


If conditions was established, it Enabled becomes False, the Timer doesn't work, there are also the interval to speak...
Execution of the code to enable, what problem???

CodePudding user response:

Oh, I'm wrong, sorry...
I thought it was for my answer, so you are reply to your questions

CodePudding user response:

Whether can register a management services program, and then call the corresponding services, the identity of the background has WINDOWS management program, another executive program with you, with or without interface? Is the console program and network transmission, etc.,

CodePudding user response:

Task plan!

CodePudding user response:

Task planning is the standard solution, you want to test time, or a service can be also (task plan itself is one of the services of svchost), no principle,

CodePudding user response:

Using the TIMER can, have the code above,

CodePudding user response:

reference 14 floor response:
in addition to the planning task,
CreateWaitableTimer/SetWaitableTimer to complete the timing routines for a long period of time.
The next time interval was calculated by the current time (time) and SetWaitableTimer, and then wait for the signal, the signal, the time for it. The error less than 1 second
Or directly in SetWaitableTimer set the absolute time of the next, and then is waiting for the signal.
And it is said that can let the computer recovery standby (this I didn't try... )
.

This is the truth

CodePudding user response:

The method has a lot of,
Relatively simple approach is to use two Timer, a used to determine the current time, time is 9 PM to 3 points of time, to determine whether timer2 true, isn't it is set to true, other time to determine whether timer2 false, false, is not false set

CodePudding user response:

Task plan comparison

CodePudding user response:

Under this program, please change to 9 o 'clock in the morning until half past eleven, 1 PM to 3 PM insert how to modify the
Whether that is modified
The interval or the default of 1000

Timer1Timer events:
Var
D: TDateTime;
H, T: string;
The begin
D:=Now;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related