I have to make a daily task (Job) which will run (7 am to 7 pm) in a day at an interval of 3 hours. Timings are as (7:00 am, 10:00 am,13:00 pm,16:00 pm,19:00 pm). But at each time when task will run i have to set a variables as per below condition
1) If task run at 2019-03-19 07:00 am in morning
I have to set two variables (start and end) whose value will become like this
(set starttime= 2019-03-09 07:00:00.00 and set endtime=2019-03-09 10:00:00.00)
2) But if task run at 2019-03-19 10:00 am in morning, the value should change as per below
(set starttime= 2019-03-09 10:00:00.00 and set endtime=2019-03-09 01:00:00.00
For setting the above variable as (set startime=2019-03-09 07:00:00.00) at 07.00 am on a particular day.
I can use ($ztimestamp) to get UTC time and then convert it into local time i am using the below way is this correct?
This will change the current time stamp to local time . Means if task will run at 07:00 am in morning , the above 3 commands automatically set the start time to 2019-03-19 07:00:00.00
My Question is how i can program this task in the below way
how can i know that task is running at 07:00 am so to set variable as (set starttime= 2019-03-09 07:00:00.00 and set endtime=2019-03-09 10:00:00.00)
if task is running at 10:00 am so to set variable as (set starttime= 2019-03-09 10:00:00.00 and set endtime=2019-03-09 13:00:00.00)
if task is running at 13:00 pm so to set variable as (set starttime= 2019-03-09 13:00:00.00 and set endtime=2019-03-09 16:00:00.00)
if task is running at 16:00 pm so to set variable as (set starttime= 2019-03-09 16:00:00.00 and set endtime=2019-03-09 19:00:00.00)
is there any property of %sys.task to tell me that the current time is 07:00 am , 10:00 am or etc . so that i can set my variable accordingly.