Documentation/Calc Functions/EOMONTH
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Function name:
EOMONTH
Category:
Date and Time
Summary:
Calculates the date of the last day in the month that is a specified number of months before or after a given date. EOMONTH can be used to determine different types of end / due date that fall at the end of the month.
Syntax:
EOMONTH(StartDate; Months)
Returns:
Returns an integer date-time serial number which represents the new date. The returned value is formatted as a number 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 start date for which the calculation is to be carried out.
Months is an integer value or a reference to a cell containing that value, which is the number of months to be added to StartDate. Positive, zero, and negative values are accepted. Negative values result in dates that are earlier than StartDate, while positive values result in dates that are later than StartDate.
- If StartDate does not contain a valid date expression, then EOMONTH reports a #VALUE! error.
- EOMONTH ignores any time components of StartDate. Also, the day component of StartDate is not significant to EOMONTH’s calculation.
- If Months is non-numeric, then EOMONTH reports a #VALUE! error.
- If Months is a non-integer value, then EOMONTH truncates it to an integer.
Additional details:
General information about Calc's Date and Time functions
- 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 ▸ ▸ ▸ 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 ▸ ▸ ▸ 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 result2021-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 ▸ ▸ ▸ and pressing the 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 |
---|---|---|
=EOMONTH("2020-11-15"; 6) | Here the function returns the date-time serial number for the date of the last day in the month that is six months after 2020-11-15. The value 44347 is returned, which corresponds to 2021-05-31. | 44347 |
=EOMONTH(44242; −3) | The value 44242 is the date-time serial number for 2021-02-15. Here the function returns the date-time serial number for the date of the last day in the month that is three months before 2021-02-15. The value 44165 is returned, which corresponds to 2020-11-30. | 44165 |
=EOMONTH(A1; A2) where cell A1 contains 2020-05-31T10:57:07 and cell A2 contains -3.6 . |
Here the function returns the date-time serial number for the date of the last day in the month that is three months before 2020-05-31. The value returned is 43890, which corresponds to 2020-02-29. Note the truncation of the time component of the first argument and the fractional component of the second argument. | 43890 |
Related LibreOffice functions:
ODF standard:
Related (or similar) Excel functions:
EOMONTH