Run Condition Examples:
The work of the assistant who has the system works for one condition. The Assistant is specially selected for these conditions. After clicking the Run Condition tab, a Run Condition query must be written.
If there is no condition for the assistant to work, SELECT 1 should be written in this field.
Example 1:
It may be desirable to work the defined assistant every weekday on the weekend. In this case, a query must be written in the RUN condition course with the working condition.
SELECT CASE WHEN DATENAME (Weekday,getdate()) in ('Sunday','Saturday') then 0 else 1 end
DATENAME application is used in the configured query. This content does not include any that do not specify a date. With the getdate function, the assistant will not be used, as it will take advantage of the Saturday - Sunday, which you will look at the next day after its use. It is an exhibition according to the desired days by changing the terms Sunday and Saturday.
Example 2: It may be desired to start the assistant defined at 13:00 every day. In this case, a query like this should be written in the RUN condition field in the Working Condition tab.
SELECT CASE
WHEN DATEPART(HOUR,GETDATE())='13' THEN 1
ELSE 0 END
The DATEPART function is used in the query written above. The DATEPART function returns a specified portion of the given date. The GETDATE function is used as the given date.
As a result of the operation, the assistant will look at the current time and will work at 13 o'clock.
* In line with this usage, you will definitely need to run the assistant every 60 minutes.
Example 3: It may be desired that the defined assistant starts at 9:30 in the morning and at 17:30 in the evening. In this case, a query like this should be written in the RUN condition field in the Working Condition tab.
SELECT CASE
WHEN CONCAT(DATEPART(HOUR,GETDATE()),DATEPART(MINUTE,GETDATE()))='930' THEN 1
WHEN CONCAT(DATEPART(HOUR,GETDATE()),DATEPART(MINUTE,GETDATE()))='1730' THEN 1
ELSE 0 END
In this written query, the hour and minute values from the instant date information are taken with the DATEPART function and combined with the CONCAT expression.
DATEPART(HOUR,GETDATE()) ---> Retrieves time information from the current time zone.
DATEPART(MINUTE,GETDATE()) ---> Retrieves minute information from current time zone.
As a result of the meeting, 09:30 in the morning; to the value of 930
5:30 p.m.; It will be equal to the value 1730.
As a result of this query, the assistant defined every day at 9:30 in the morning and at 17:30 in the evening will be activated.
* In line with this usage, you can run the assistant every minute. If you want to run it every 60 minutes, you will need to set the Assistant start time on the Assistant definition screen to a half hour, such as 12:30, 13:30, 14:30 .......