Documentation/Calc Functions/DATE

Other languages:

DATE

Category:

Date and Time

Summary:

Calculates the date (as a date-time serial number) for the given year, month, and day of the month values.

Syntax:

DATE(Year; Month; Day)

Returns:

Returns an integer value which is the date-time serial number calculated using the given arguments. The returned value is formatted as a date by default, but you can apply other formats as needed.

Arguments:

Year is a non-negative integer value or a reference to a cell containing that value, which is the year to be used. Values in the range 0 to 99 are converted to four-digit years in accordance with the Year (Two Digits) setting on the Tools ▸ Options ▸ LibreOffice ▸ General dialog. However, to avoid confusion it is better to always use four-digit years.

Month is an integer value or a reference to a cell containing that value, which is the month to be used. Both positive and negative values are accepted; values outside the normal range of 1 to 12 result in carryover to the calculated year value.

Day is an integer value or a reference to a cell containing that value, which is the day to be used. Both positive and negative values are accepted; values outside the normal range (1 to 31, dependent on month) result in carryover to the calculated month value.

• If any of Year, Month, or Day is non-numeric, then DATE reports a #VALUE! error.
• If any of Year, Month, or Day is a non-integer value, then DATE truncates it to an integer.
• If no value is provided for the Year argument (for example, =DATE(; 1; 1)), then DATE reports a missing variable error (Err:511). If no value is provided for either the Month or the Day argument (for example, =DATE(2021; ; )), then DATE applies a default value of 0.
• If the value of the Year argument is negative, then DATE reports an invalid argument error (Err:502).
• If DATE calculates a date-time serial number that corresponds to a date prior to 1582-10-15 (before the Gregorian calendar was introduced), DATE reports a #VALUE! error.
• ODF 1.2 requires that DATE accept year values up to and including 9956. Calc’s implementation will process year values larger than this limit.

General information about Calc's Date and Time functions

 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 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
=DATE(21; 1; 31) with the cell formatted to show an ISO 8601 date and two-digit years interpreted as being in the range 1930 - 2029. Here the function returns the date as a date-time serial number and displays it in the applied date format. 2021-01-31
=DATE(2020; 13; 41) with the cell formatted to show an ISO 8601 date. Here the function returns the date as a date-time serial number and displays it in the applied date format. The specified month is outside its natural range and this results in carryover to the year value. Similarly the specified day is outside its natural range and this results in carryover to the month value. 2021-02-10
=DATE(YEAR(A1)+5; MONTH(A1)-2; DAY(A1)/3) with the formula cell formatted to show an ISO 8601 date and cell A1 containing the date 2021-01-31. Here the function gets the year, month, and day values from cell A1 and performs the mathematical operations. It returns the new date as a date-time serial number and displays it in the applied date format. 2025-11-10
=DATE(1582; 10; 15-1) Here the function returns an error because the date calculated is before the Gregorian calendar was introduced. #VALUE!

DATE