Kernel 8.0 APIs Banner
Office of Information and Technology (OIT) Banner
[skip navigation]

$$EN^XUWORKDY: Number of Workdays Calculation

Reference Type: Supported, Category: Miscellaneous, ICR#: 10046

Description

NOTE: This API is dependent on the HOLIDAY (#40.5) file being updated by the sites.

To use the ^XUWORKDY APIs, you must make sure that the HOLIDAY (#40.5) file is populated with each year's holidays for the workday calculation to work correctly. If it is not populated, you need to populate it yourself (Kernel distributes this file without data). Only enter holidays that fall on weekdays, however.

The $$EN^XUWORKDY extrinsic function is used to calculate the number of workdays between two dates (date1, date2). It returns:

The first FOR loop in ^XUWORKDY checks the HOLIDAY global and sets %H equal to the number of holidays between the two dates. It is assumed that the HOLIDAY global contains only weekday holidays.

The second FOR loop (F %J=%J:1 ... ) steps forward from the earliest date and stops at the first Sunday or at the ending date (whichever comes first) counting the number of workdays.

The third FOR loop (F %K=%K:-1 ... ) steps backward from the latest date and stops at the first Sunday or at the beginning date (whichever comes first), counting the workdays.

Then %I is set equal to the number of days between the two Sundays.

Finally, the return value is set equal to the total counted days minus the number of weekend days between the two Sundays [-(%I\7*2)].

Format

  $$EN^XUWORKDY(date1,date2)

Input Parameters

date1:

(required) Starting date in VA FileMan internal format (e.g., 2850420).

date2:

(required) Ending date in VA FileMan internal format (e.g., 2850707).

Output

returns:

Returns the number of workdays in the interval.

 

Example

>W $$EN^XUWORKDY(3090102,3090108)
4