Documentation/Calc Functions/WORKDAY.INTL

From The Document Foundation Wiki
Jump to navigation Jump to search

Function name:

WORKDAY.INTL

Category:

Date and Time

Summary:

Calculates the date which is a specified number of workdays before or after a given start date. Holidays (or other non-work days) can be specified and the standard workweek can be redefined.

Syntax:

WORKDAY.INTL(StartDate; Days[; [Weekend][; Holidays]])

Returns:

Returns an integer which is the date-time serial number of the day that is a specified number of workdays before or after the given date. The returned value is formatted as a date by default, but you can apply other formats as needed.

Arguments:

StartDate is the date (in quotation marks) or a date-time serial number, or a reference to the cell containing one of those types, which is the date for which the calculation is to be carried out.

Days is an integer value or a reference to a cell containing that value which is the number of workdays to be used as the offset in the calculation. A positive value is entered to get a result later than StartDate, a negative value is entered to get a result earlier than StartDate.

Weekend is a number or a string, or a reference to the cell containing one of those types, that is used to define the standard workweek to be used. The available numeric options provide a simple way to define the workweek, with the list of possible values given in the following table. Values 1 to 7 correspond to workweeks with two non-work days, while values 11 to 17 correspond to workweeks with one non-work day.

Number Non-Work Days
1 or omitted Saturday and Sunday
2 Sunday and Monday
3 Monday and Tuesday
4 Tuesday and Wednesday
5 Wednesday and Thursday
6 Thursday and Friday
7 Friday and Saturday
11 Sunday only
12 Monday only
13 Tuesday only
14 Wednesday only
15 Thursday only
16 Friday only
17 Saturday only

Using a string is a more flexible method to define the workweek. The string must comprise seven characters – '0' is used to indicate a workday and '1' is used to indicate a non-work day. Each character corresponds to a day of the week, starting with Monday. For example, the string "0100011" would define Tuesday, Saturday, and Sunday as non-work days.

Holidays is a list of dates corresponding to holidays that are not to be counted as workdays. This list can be passed as a range of cells containing date-time serial numbers (possibly displayed in a date format). Alternatively, the list can be passed as an inline array containing either date strings (in quotation marks) or date-time serial numbers. If omitted, no holidays are assumed.

  • If StartDate is not a valid date expression, then WORKDAY.INTL reports a #VALUE! error.
  • WORKDAY.INTL ignores any time components of StartDate.
  • If Days is non-numeric, then WORKDAY.INTL reports a #VALUE! error.
  • If Days is a non-integer value, then WORKDAY.INTL truncates it to an integer.
  • If a string is used for the Weekend argument, and that string does not contain exactly seven characters, WORKDAY.INTL reports a #VALUE! error. If the string does contain seven characters, but at least one of those characters is neither a '0' nor a '1', then WORKDAY.INTL reports an invalid argument error (Err:502).
  • If a number is used for the Weekend argument, and that number is not an integer value, then WORKDAY.INTL reports an invalid argument error (Err:502). If the number is an integer value but does not lie in either the range 1 to 7 or the range 11 to 17, then WORKDAY.INTL reports an invalid argument error (Err:502).
  • If Weekend is passed as a cell reference and that cell contains an error code (such as #NAME?), that error status will be propagated as the result of WORKDAY.INTL.
  • If Holidays is passed as an inline array, and any entry of that array is not a date or a date-time serial number, then WORKDAY.INTL reports a #VALUE! error.
  • If Holidays is passed as a cell range, then in most cases cells that do not contain a date or a date-time serial number lying within the relevant period are ignored. However, if a cell contains an error code (such as #NAME?), that error status will be propagated as the result of WORKDAY.INTL.

Additional details:

Details specific to WORKDAY.INTL function

The order of the optional Holidays and Weekend parameters is different for WORKDAY.INTL when compared to the specification in ODF 1.2. Also, the definition of the Weekend parameter for Calc’s WORKDAY.INTL is extended compared to the corresponding Workdays parameter in ODF 1.2. However, Calc's WORKDAY.INTL function is compatible with Excel's function of the same name.

General information about Calc's Date and Time functions

Note pin.svg

For convenience the information in this subsection is repeated on all pages that describe functions in the Date and Time category.


  • Internal to Calc, a date/time value is handled as a real number and this is sometimes referred to by the term date-time serial number. For example, 2021-02-08 12:00:00 corresponds to the date-time serial number 44235.5. The integer part of a date-time serial number (before the decimal point) is the number of days since a defined start date. The fractional part of a date-time serial number (after the decimal point) is the time of day expressed as a fraction of a day. For example, 0.25 is equivalent to 06:00:00 and 0.75 is equivalent to 18:00:00.
  • Calc uses 1899-12-30 as the default start date (day 0) but you can go to Tools > Options > LibreOffice Calc > Calculate to select alternative start dates; however, unless you have specific requirements for compatibility with legacy spreadsheet applications, we recommend that you do not change this setting. If you copy and paste cells containing date values between different spreadsheets, check that both documents are set to use the same start date to avoid unexpected changes to the dates displayed.
  • Negative date-time serial numbers correspond to dates earlier than Calc's start date. Calc calculates all dates back to 15th October 1582 using the Gregorian calendar. The day before this is 4th October 1582, and Calc uses the Julian calendar for earlier dates.
  • A date-time serial number is the same as any other number, except that we usually choose to display it formatted as a date/time. You can enter a number in a cell and then change the cell’s formatting to display the value as a date/time. You can also enter a date/time in a cell and then change the cell’s formatting to display the date-time serial number.
  • For clarity, the descriptions of the Calc functions within these wiki pages use the standard ISO 8601 format for date and time because this should be independent of your selected locale settings. The default date format on your computer may be different. When entering dates as part of formulas, slashes or dashes used as date separators may be interpreted as arithmetic operators. Therefore, dates entered in this format are not recognized as dates and result in erroneous calculations. To keep dates from being interpreted as parts of formulas either use the DATE function or place the date in quotation marks and use the ISO 8601 notation. Avoid using locale dependent date formats which may produce errors if the document is loaded under different locale settings.
  • Time zone information is not used by Calc’s Date & Time functions.
  • If you only wish to enter two digits of the year (for example 21 instead of 2021), Calc needs to know whether you mean 2021 or 1921. Go to Tools > Options > LibreOffice > General to view or adjust the range of years which Calc will use to interpret two-digit year values.
  • Calc contains logic to decide how to treat text when encountered as an operand in an arithmetic operation or as an argument to a function that expects a number instead. In this context, unambiguous conversion is possible for ISO 8601 dates and times in their extended formats with separators. For example, the simple formula =1 + "2021-02-08" will usually give the result 2021-02-09 (when formatted as a date). However, this logic may be affected by the settings on the Detailed Calculation Settings dialog, accessed by selecting Tools > Options > LibreOffice Calc > Formula and pressing the Details button in the Detailed Calculation Settings area. If a #VALUE! error occurs, it may be because the Generate #VALUE! error option is selected, in which case you should experiment with one of the other self-explanatory options in the Conversion from text to number drop-down.

Examples:

Formula Description Returns
=WORKDAY.INTL("2021-02-10"; 10) The function returns 2021-02-24. The day that is 10 working days after 2021-02-10 is 2021-02-24. 2021-02-24
=WORKDAY.INTL(44256; -5.8) The function returns 2021-02-22. The value 44256 is the date-time serial number for 2021-03-01. Calc truncates the real value -5.8 to the integer -5. The day that is 5 working days before 2021-03-01 is 2021-02-22. 2021-02-22
=WORKDAY.INTL("2020-01-01"; 254;; {"2020-01-01"; "2020-04-10"; "2020-04-13"; "2020-05-08"; "2020-05-25"; "2020-08-31"; "2020-12-25"; "2020-12-28"}) The function returns 2021-12-31. The day that is 254 working days later than 2020-01-01 is 2021-12-31, taking account of the listed holiday dates. 2021-12-31
=WORKDAY.INTL(G1; G2;; G3:G7) where cell G1 contains the date 2001-12-01, cell G2 contains the value 17, and cells G3 to G7 contains the dates 2001-12-24, 2001-12-25, 2001-12-26, 2001-12-31, 2002-01-01. The function returns 2001-12-28. 2001-12-28 was the date that came 17 workdays after 2001-12-01, taking account of the listed holiday dates. 2001-12-28
=WORKDAY.INTL("2021-02-10"; 10; 11) The function returns 2021-02-22. The day that is 10 working days after 2021-02-10 is 2021-02-22, assuming only one non-workday each week (Sunday). 2021-02-22
=WORKDAY.INTL("2021-02-10"; 10; "0000001") The function again returns 2021-02-22. The day that is 10 working days after 2021-02-10 is 2021-02-22, assuming only one non-workday each week (Sunday). 2021-02-22

Related LibreOffice functions:

WORKDAY

ODF standard:

Section 6.10.22, part 2

Equivalent Excel functions:

WORKDAY.INTL