03-24-2017 08:07 PM - edited 03-14-2019 05:10 PM
Hello.......
can someone able to give me any idea or example how to script different opening and closing hours in script so script can work automatically accordingly?
for Example if in summer opening and closing hours are 8:00 to 5:00 and in winter opening and closing hours are 8:00 to 4:30.......
so i like to make script which can work automatically in shorter and extended hour without any user intervention....
Solved! Go to Solution.
03-28-2017 07:25 AM
Sorry, there is a typo in my formula; my formula didn't match the variable names defined.
summerStartDate = "06/01/". This can be made a parameter.
summerEndDate = "09/01/". This can be made a parameter.
Corrected formula which should now compile:
If D[now] >= D[summerStartDate + D[now].year] && D[now] < D[summerEndDate + D[now].year] then
I had summerDateEnd in the formula instead of summerEndDate which is what the variable is named. If you correct the summerEndDate, the formula should not give you the error message.
Sorry about that.
First, add the 2 String variables: summerEndDate and summerStartDate. You can make them parameters if you want; that's optional and not required. If you have to change the dates, it may be easier to change the parameter in the application then editing the script and uploading the new version.
The way I would incorporate this into your test script is by replacing the IF Schedule_Selector == 1 with
D[now] >= D[summerStartDate + D[now].year] && D[now] < D[summerEndDate + D[now].year]
True: GoTo Extended Hour
False: GoTo Normal Hour
You would reverse the GoTo statements since you're now asking if the IF statement is true, you're using extended hours. Otherwise, (false) you're using normal hours.
I hope that helps.
Bill
03-26-2017 09:04 PM
03-27-2017 06:44 AM
Hello David,
Thanks for reply. yes hours are based on dates and i knew i have to add if statement in my script like...
if date falling under June to Sep go on to step 1 and if other than that go to step 2 and need to configure step 1 and 2 properly (which i think i knew how). i understanding the logic but not very good with variable so that's where i need help like but kind variable i need and how to configure if statement?
Best Regards
Sukhdeep
03-27-2017 08:30 AM
I believe you might be over thinking this, how about you set it up like this?
If date > June AND date < Sep
Go to Summer Hours Check
Else
Go to Winter Hours Check
david
03-27-2017 09:37 AM
Hello David
this is my problem not sure how to create this if statement which can check Month for me...
if its not too much too ask can you able to give me rough idea how to create one with example.....
03-27-2017 12:59 PM
Sukhdeep,
I'm sure there's a better way to do this but you can try something like this:
Create 2 string variables: summerStartDate, summerEndDate
summerStartDate = "06/01/". This can be made a parameter.
summerEndDate = "09/01/". This can be made a parameter.
If D[now] >= D[summerDateStart + D[now].year] && D[now] <= D[summerDateEnd + D[now].year] then
True: set a variable or GoTo SummerHours
False: set another variable or GoTo WinterHours
If you don't want to use 2 variables, you could also hard-code the dates like this:
If D[now] >= D["06/01/" + D[now].year] && D[now] < D["09/01/" + D[now].year] then
Using the D[now].year statement makes the script work year after year without having to hard-code the year. If the summer start date and summer end date is changed, you can adjust the variables or the hard-coded values accordingly.
If the start and end date change (instead of the 1st of the month), you can use variables that are parameters and change the values in the application page and be good.
I hope this helps.
Bill
03-27-2017 01:46 PM
Hello Bill,
thanks for reply and thanks for your detail answer. this is but i am looking for it...
i have one more question how i am going to use this D[Now] to catch current date? if you answer this for me than rest of i think i am able to handle....
at least i have something to play around now
best Regards
Sukhdeep
03-27-2017 03:07 PM
D[now] is the current date/time.
In the formula above, the D[now].year will translate to "2017." It means, get the year of the current date/time.
Bill
03-28-2017 06:53 AM
Good Morning Bill,
i am getting error messages when i tried to use your instruction(i knew i am doing something wrong or missing some kind variable) . please see attached files for errors( error.jpeg and variable.jpeg)
Second i also attached my Script "test". Please look at it if you have time and give me your advice if something wrong and how i can add your instruction. in this script right now i am using different approach for normal and extended hour but just for learning purpose i like to implement your approach.
Thanks for your all help
Best Regards
Sukhdeep
03-28-2017 07:25 AM
Sorry, there is a typo in my formula; my formula didn't match the variable names defined.
summerStartDate = "06/01/". This can be made a parameter.
summerEndDate = "09/01/". This can be made a parameter.
Corrected formula which should now compile:
If D[now] >= D[summerStartDate + D[now].year] && D[now] < D[summerEndDate + D[now].year] then
I had summerDateEnd in the formula instead of summerEndDate which is what the variable is named. If you correct the summerEndDate, the formula should not give you the error message.
Sorry about that.
First, add the 2 String variables: summerEndDate and summerStartDate. You can make them parameters if you want; that's optional and not required. If you have to change the dates, it may be easier to change the parameter in the application then editing the script and uploading the new version.
The way I would incorporate this into your test script is by replacing the IF Schedule_Selector == 1 with
D[now] >= D[summerStartDate + D[now].year] && D[now] < D[summerEndDate + D[now].year]
True: GoTo Extended Hour
False: GoTo Normal Hour
You would reverse the GoTo statements since you're now asking if the IF statement is true, you're using extended hours. Otherwise, (false) you're using normal hours.
I hope that helps.
Bill
03-28-2017 07:46 AM
Thanks bill,
i made changes accordingly and this time no error message. i will ask business can i am able to test the script and will update you with result.
Thanks for your all help and i appreciate your help.
Best Regards
Sukhdeep
04-03-2017 06:58 AM
Good Morning Bill,
thanks for your all help and with your help my script is done and it's working like charm
Best Regards
Sukhdeep
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide