Documentation/Calc Functions/WORKDAY

    From The Document Foundation Wiki
    Other languages:


    Function name:

    WORKDAY

    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. Saturday and Sunday are assumed to be the weekend non-work days.

    Syntax:

    WORKDAY(StartDate; Days[; 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 number by default, but you can apply other formats (such as Date) 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.

    Holidays is a list of dates corresponding to holidays (or any other days) that are to be excluded from the count as non-work days. 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 reports a #VALUE! error.
    • WORKDAY ignores any time components of StartDate.
    • If Days is non-numeric, then WORKDAY reports a #VALUE! error.
    • If Days is a non-integer value, then WORKDAY truncates it to an integer.
    • If Holidays is passed as an inline array, an invalid argument error (Err:502) results if any entry of that array is not a date or a date-time serial number.
    • If Holidays is passed as a cell range and one of those cells contains data that is not a date or a date-time serial number, WORKDAY reports an invalid argument error (Err:502).

    Additional details:

    Details specific to WORKDAY function

    WORKDAY normally considers Monday to Friday to be workdays, unless a particular day coincides with a specified holiday. The normal weekend days of Saturday and Sunday are taken as non-work days.

    Calc's WORKDAY function does not support the optional Workdays parameter that is specified in ODF 1.2 but is compatible with Microsoft Excel’s function of the same name. If you need to specify a different working week, then use Calc’s WORKDAY.INTL function.


    General information about Calc's Date and Time functions

    Note pin.svg

    Note:
    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 separator) is the number of days since a defined start date. The fractional part of a date-time serial number (after the decimal separator) 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("2021-02-10"; 10) The function returns the value 44251, which is the date-time serial number for 2021-02-24. The day that is 10 workdays after 2021-02-10 is 2021-02-24. 44251
    =WORKDAY(44256; -5.8) The function returns the value 44249, which is the date-time serial number for 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 workdays before 2021-03-01 is 2021-02-22. 44249
    =WORKDAY("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 the value 44196, which is the date-time serial number for 2020-12-31. The day that is 254 workdays later than 2020-01-01 is 2020-12-31, taking account of the listed holiday dates. 44196
    =WORKDAY(G1; G2; G3:G7) where cell G1 contains the date 2001-12-01, cell G2 contains the value 17, and cells G3 to G7 contain the dates 2001-12-24, 2001-12-25, 2001-12-26, 2001-12-31, 2002-01-01. The function returns the value 37253, which is the date-time serial number for 2001-12-28. 2001-12-28 was the date that came 17 workdays after 2001-12-01. 37253

    Related LibreOffice functions:

    WORKDAY.INTL

    ODF standard:

    None.

    Related (or similar) Excel functions:

    WORKDAY