Algorithm For Scheduling Around Weekends And Holidays

Similar documents
BUP2 5/2 12/4/07 12:49 AM Page 1. Introduction

Conditional Formatting

MyOwnDeliveries. a Magento module. User manual

BUT2 7day 11/4/07 11:07 PM Page 1. Introduction

Scheduling. Scheduling Tasks At Creation Time CHAPTER

AIMMS Function Reference - Date Time Related Identifiers

OPERATING MANUAL- MODEL : BS-101

Total Market Demand Wed Jul 26 Thu Jul 27 Fri Jul 28 Sat Jul 29 Sun Jul 30 Mon Jul 31 Tue Aug 01

Elixir Schedule Designer User Manual

Microsoft Excel 2013 Series and Custom Lists (Level 3)

Maintaining the Central Management System Database

Payflow Implementer's Guide FAQs

SARS ANYWHERE ADMINISTRATION MANUAL INDEX

Package bizdays. June 25, 2018

Calendar PPF Production Cycles Non-Production Activities and Events

PASCAL. PASCAL, like BASIC, is a computer language. However, PASCAL, unlike BASIC, is a Blocked Structured Language (BASIC is known as unstructured).

SOUTH DAKOTA BOARD OF REGENTS. Board Work ******************************************************************************

Real Time Clock. This appendix contains the information needed to install, program, and operate the Real Time Clock (RTC) option.

CIMA Certificate BA Interactive Timetable

DSC 201: Data Analysis & Visualization

IVR (Interactive Voice Response) Operation Manual

Phone Numbers. Phone Numbers. British Telecom (BT) Service:

Module: mylink administration tool

Bill Pay Upgrade Scheduled July 14!

Study Guide Processes & Job Control

Austin Community College Google Apps Calendars Step-by-Step Guide

Application Guide. BACnet Scheduling Tips. Overview. General Principles. For KMC BACnet Controllers

ACT! Calendar to Excel

MONITORING REPORT ON THE WEBSITE OF THE STATISTICAL SERVICE OF CYPRUS DECEMBER The report is issued by the.

The David Attenborough Essential Collection CAMPAIGN DETAILS

EECS402 Lecture 24. Something New (Sort Of) Intro To Function Pointers

Global Commerce Review. United States, Q1 2018

Unit 6: Groups, Teams, and Managing Users

Instrument Parts I began in Access by selecting the Create ribbon, then the Table Design button.

CROWN JEWEL SOFTWARE FOR WINDOWS SOFTWARE REV.

Model: TM-1 / TM1-N. 1 Time Clock Series

Enumerated Types. Mr. Dave Clausen La Cañada High School

Table of Contents UFA Credit Account Application... 9 Card Link Online Account Management User Management... 71

While You Were Sleeping - Scheduling SAS Jobs to Run Automatically Faron Kincheloe, Baylor University, Waco, TX

MyOwnDeliveries. a Magento 2 module. User manual

Table of Contents UFA Credit Account Application... 9 Card Link Online Account Management User Management... 77

SOUTH DAKOTA BOARD OF REGENTS. Board Work ******************************************************************************

SWITCH(DatePart("w",DateOfYear) IN(1,7),"Weekend",DatePart("w",DateOfYear) IN(2,3,4,5,6),"Weekday") AS DayType,

Marketing Whitepaper: 8 Steps To Increasing Your Sales With Marketing

Substitute Quick Reference (SmartFindExpress Substitute Calling System and Web Center)

Object-Oriented Principles and Practice / C++

Private Swimming Lessons

Creating A Simple Calendar in PHP

SUMMER Early Registration Begins On... Summer Hours. Tuition (per child): JUNE 2019

Helpdesk. Shopping for Technology. Talkin Tech Highlights... Computing on the Go!

REV SCHEDULER (iseries)

Lecture 3. The syntax for accessing a struct member is

Before creating and applying tags, it's important to understand the different types of tags available.

Job sample: SCOPE (VLDBJ, 2012)

SOUTH DAKOTA BOARD OF REGENTS PLANNING SESSION AUGUST 8-9, Below is a tentative meeting schedule for the Board meetings in 2013:

Configuring Cisco Access Policies

Nimsoft Monitor. reboot Guide. v1.4 series

Skybot Scheduler User Guide

CS1101: Lecture 9 The Shell as a Programming Language

USER GUIDE. Biometric Attendance Software.

Using Platform Process Manager. Platform Process Manager Version 7.1 July 2009

Introduction CJ s Cross-Device Tracking Solution Key Strategies Shopping & Device Paths Average Order Value...

San Diego Unified School District Substitute Reference Guide

Programming in Haskell Aug-Nov 2015

WebCalendar User Manual

INTRODUCTION TO DESIGN. Scenarios and conceptual design * Interaction objects, properties, relationships * Different views * Access and operations

76 days Wed 8/24/16 Wed 12/7/16 Daniel Wang,Shreyas Makde,Madhavi Potluri,Roua 2 Requirements analysis 11 days Wed 8/24/16 Wed 9/7/16

Genesys Info Mart. date-time Section

I. Connecting the Device.

Part No. P CallPilot. Programming Record

PART 3 AUTUMN. first half UNIT 4 HANDLING DATA. Bar charts and bar line graphs SECTION 1. Charts and tables SECTION 2. Mode and range SECTION 3

OPERATING MANUAL FOR AUTOMATIC SCHOOL BELL Ringing bell in manual mode: When unit is at Home Screen, showing date and time on

TELEPHONE ACCESS INSTRUCTIONS

Virtual EMS AV Request Form Guide New England Law

Setup guide for ebanking

2018 weekly planner 8 pdf Weekly calendar 2018 for PDF - 12 free printable templates Free Weekly Schedule Templates for PDF - 18 templates

UPCOMING PROGRAMMES/COURSES APRIL 2016 MARCH 2017 (MIND KINGSTON & MANDEVILLE CAMPUSES)

Time Guardian Plus. Time and Attendance Software (with Access Integration) User s Guide

SAP. Modeling Guide for PPF

Chapter 10 Protecting Virtual Environments

Introduction to OffDuty Wizard

Chapter 3. Ch 1 Introduction to Computers and Java. Selections

CSCI 150: Exam 1 Practice

1. Contact Please use this first form to give details of the main contact at your property.

Substitute Quick Reference Card

Digital Rates 2018/2019 Online, Mobile, Digital. September 2018

RWB29 Programmer. Daily Programming

Double Your Affiliate Commissions with this VERY Simple Strategy

Case Status Alerts User Guide

Why Jan 1, 1960? See:

Software Programming Guide. A 4510 Software Programming Guide A 4510 Yearly Timer. Redback Proudly Made In Australia

Printing a Monthly Calendar Updated: November 4, 2015

Wimbledon Ballot Ballot Administrator Step By Step Guide

Administrator user guide. mybusiness Essentials Payslip

TA Document AV/C Bulletin Board Type Specification Resource Schedule Board 1.0a

Practice for Test 1 (not counted for credit, but to help you prepare) Time allowed: 1 hour 15 minutes

Daily Math Week 8 ( ) Mon. October 7, 2013 Tues. October 8, 2013 Wed. October 9, 2013 Thurs. October 10, 2013 Fri.

DOC // USPS PACKAGE DIDN'T ARRIVE

2014 FALL MAILING SEASON Update for the Mailing Industry. August 18, 2014

Timetable 19 March 2018 to 25 June Please read the following booking notes before completing and returning your application form.

Transcription:

Algorithm For Scheduling Around Weekends And Holidays Scott Auge scott_auge@amduus.com sauge@amduus.com Introduction We have all heard the phrase x business days for something to be delivered or done. It could be sales goods to a buyer, inventory moving between warehouses for manufacture or distribution, among other uses. We recognize that business days doesn't include the weekends or holidays. But how do we quickly calculate that? That will be the point of this article. First off are holidays. Some holidays move around on the calendar, so one cannot simply mark days off programmatically. Some companies will use federal holidays while others are more discerning. Also, if your application is meant to be used internationally one cannot mark days off we need a database table to hold the dates of holidays. The second is the weekends. Luckily Progress ABL has a function called WeekDay() that will return 1 through 7 for Sunday through Saturday. It returns a number because it can be used with many languages internationally hence it is up to you for the preferred language. We also want a routine that can be used is WWW, GUI, and character programs. I use Progress Advanced Business Language because it is a pretty straight forward language and should be easily translated into others. Don't get caught up in the use of a character interface, the routine can work in GUI and WWW too. (Progress runs in all three environments.) It is just easier to test in character when I am on a UNIX computer. More information about Progress can be found at http://www.progress.com. A Database Table Needed First we need to create a database table to hold dates that will effect the scheduling of a job regarding holidays, days off, and the like. This will provide the general elements and types of the table if one wishes to put it in your own Progress application or translate it to another database: 06/17/15 10:08:51 PROGRESS Report Database: test (PROGRESS) ========================================================================= ============================= Table: Holiday ============================ Table Flags: "f" = frozen, "s" = a SQL table Table Table Field Index Table Name Flags Count Count Label -------------------------------- ----- ----- ----- ------------------------ Holiday 2 1 Holiday Dump Name: holiday Description: Dates for schedule effecting holidays Storage Area: Schema Area ============================= FIELD SUMMARY ============================= ============================= Table: Holiday ============================ Flags: <c>ase sensitive, <i>ndex component, <m>andatory, <v>iew component Order Field Name Data Type

Flags ----- -------------------------------- ----------- ----- 10 Name char 20 MDY date i Field Name Format -------------------------------- ----------------------------- Name x(8) MDY 99/99/99 Field Name Initial -------------------------------- ----------------------------- Name MDY? Field Name Label Column Label ------------------------------ ---------------------- ---------------------- Name Name Name MDY Date Date ============================= INDEX SUMMARY ============================= ============================= Table: Holiday ============================ Flags: <p>rimary, <u>nique, <w>ord, <a>bbreviated, <i>nactive, + asc, - desc Flags Index Name Cnt Field Name ----- -------------------------------- --- --------------------------------- pu pu 1 + MDY ** Index Name: pu Storage Area: Schema Area ============================= FIELD DETAILS ============================= ============================= Table: Holiday ============================ ** Field Name: Name Description: Name of the holiday ** Field Name: MDY Description: Date of the holiday Creating Sample Data Next, we need to create dates in the table... here is a quick Progress ABL program to create records in GUI and Character interfaces: define variable TheName as character no-undo. define variable TheDate as date noundo. update TheName TheDate. create Holiday. assign Holiday.Name = TheName Holiday.MDY = TheDate. The records we created: Name Date new year 01/01/15 Co Hol 01/02/15 We are going to use 12/31/14 as the start date for a sample set of data to use, so lets look at our days used: define variable increment as integer no-undo. /* Convert a date into it's week day designation */

function WeekDayName returns character (input Thedate as date): return entry(weekday(thedate), "Sun,Mon,Tues,Wed,Thur,Fri,Sat"). end. repeat: display 12/31/14 + increment WeekDayName(12/31/14 + increment). increment = increment + 1. if increment > 10 then leave. end. /* repeat */ Which returns us: 12/31/14 Wed 01/01/15 Thur 01/02/15 Fri 01/03/15 Sat 01/04/15 Sun 01/05/15 Mon 01/06/15 Tues 01/07/15 Wed 01/08/15 Thur 01/09/15 Fri We see our two holiday entries, which are Thursday and Friday. We see also that they border on the weekend. So now we have an idea of the data set now the program! The comments should be able to clue in the reader what is going on. Remember this in your programming! /* MoveScheduleDate.p Compute date in business days from a start date and number of days. Scott Auge 06/17/2015 Init */ define input parameter NumberOfDays as integer no-undo. define input parameter StartDate as date no-undo. define output parameter NewDate as date no-undo. define variable BusinessDays as integer no-undo. /* Start our date holder and business days holder */ NewDate = StartDate. BusinessDays = 0. repeat: /* These a means of catching extremes - if zero days, we are happy */ /* with what we have! */ if NumberOfDays = 0 then leave.

/* Using ABLs date tools, is the NewDate a weekend? We do this first */ /* because if even a Holiday is on a weekend, we want all weekends to */ /* to be overlooked. */ if weekday(newdate) = 1 or weekday (NewDate) = 7 then do: NewDate = NewDate + 1. next. end. /* if weekday(newdate) = 1 or weekday (NewDate) = 7 */ /* Is the current date a holiday? We don't actually pull back */ /* the record, just if we can find it. */ if can-find(holiday where Holiday.MDY = NewDate) then do: NewDate = NewDate + 1. next. end. /* if can-find(holiday where Holiday.MDY = NewDate) */ /* We got through weekends and holidays, so add in a business day */ BusinessDays = BusinessDays + 1. NewDate = NewDate + 1. /* Determine if we are ready to bail? */ if BusinessDays = NumberOfDays then leave. end. /* repeat */ Testing Over Our Data Set Now it is time to test the routine. The first screen shot is a quick test program that will be used to generate the results.

Running the program we get

We see that the routine recognizes that the first and the second are holidays from the database table. Then it uses Progresses built in function to recognize the days after are weekends. It then counts the number of days and calculates a new date for delivery or scheduling. Conclusion Having a business days scheduler is one of the most basic date routines available in applications that hope to have a real user base. So many applications I have seen that do not have this simple algorithm! What should be interesting to those who manage is not just the creation of the program that originally started all this, but the creation of a program to add holidays, a program to see what data we need to contend with, and the creation of a test program. So to make this one routine, four programs all together were written. User-wise, the database table Holidays will need to be kept up. So there is a combination of user and programmer involvement in the creation of this routine and it's usefulness. Thanks for reading this and I hope you keep an eye out on www.amduus.com for new articles! Addendum As a viewer (Tex Texin a very good resource) reviewed this paper, he mentioned some international

companies have different weekends that the US. I would suppose this is Friday for muslim countries, Saturday for Jewish countries... and some may have none. (I'm not going into detail on that one.) So this is good for the reader to know. I would also point out, that weekends can be overlooked for truck and train transport. So, the algorithm should be improved based on that it can become very complicated based on what the customer is doing and where. About the author: Scott Augé is the founder and president of Amduus Information Works, Inc. He has been programming in the Progress environment since 1994. His works have included e-business initiatives and focuses on web applications on UNIX platforms. His contact information is at linkedin.com at https://www.linkedin.com/in/scottauge/en.