Question
· Mar 9, 2019

%SYS.TasK Related query

Hi Community,

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

Sample:

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.

Query:1

I can use ($ztimestamp) to get UTC time and then convert it into local time i am using the below way is this correct?

 SET stamp=$ZTIMESTAMP
w !,stamp
SET localutc=$ZDATETIMEH(stamp,-3)
w $ZDATETIME(localutc,3,1,2)

 

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

Query 2

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. 

Please assist

Discussion (3)1
Log in or sign up to continue

I can use ($ztimestamp) to get UTC time and then convert it into local time i am using the below way is this correct?

 SET stamp=$ZTIMESTAMP
w !,stamp
SET localutc=$ZDATETIMEH(stamp,-3)
w $ZDATETIME(localutc,3,1,2)

Yes, sure.

My Question is how i can program this task in the below way

You heed to add three hours.  Use DATEADD method for this:

write $SYSTEM.SQL.DATEADD("hour", 3, yourDate)

Thanks for the reply. This is only for the date i guess not timestamp, is there any direct command for this.

 But Now i want this way

I want the data between (2019-3-09 07:00:00.00 to 2019-3-09 10:00:00.00)

if task run at 10:00 am ( i will set End time : 2019-03-09 10:00:00 (with the help of above 3 commands) but how to set the start time which i need of 2019-03-09 07:00:00 means i have to go 3 hours before of current timestamp).

Also my property is type of %Timestamp only . Which command i can use to subtract the currenttimestamp with 3 hours .