DATE function

This article describes the formula syntax and usage of the DATE function (function: A prewritten formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that perform lengthy or complex calculations.) in Microsoft Office Excel.

Description

The DATE function returns the sequential serial number that represents a particular date. For example, the formula

=DATE(2008,7,8)

returns 39637, the serial number that represents 7/8/2008.

 Note   If the cell format was General before the function was entered, the result is formatted as a date instead of a number. If you want to view the serial number, or if you want to change the formatting of the date, select a different number format in the Number group of the Home tab.

The DATE function is most useful in situations where the year, month, and day are supplied by formulas or cell references. For example, you might have a worksheet that contains dates in a format that Excel does not recognize, such as YYYYMMDD. You can use the DATE function in conjunction with other functions to convert the dates to a serial number that Excel recognizes. See the table in the Example section of this article for more information.

Syntax

DATE(year, month, day)

The DATE function syntax has the following arguments (argument: A value that provides information to an action, an event, a method, a property, a function, or a procedure.):

  • year    Required. The value of the year argument can include one to four digits. Excel interprets the year argument according to the date system your computer is using. By default, Microsoft Excel for Windows uses the 1900 date system; Microsoft Excel for the Macintosh uses the 1904 date system.

 Tip   We recommend using four digits for the year argument to prevent unwanted results. For example, using "07" returns "1907" as the year value.

ShowHow does Excel for Windows work with the 1900 date system?

  • If year is between 0 (zero) and 1899 (inclusive), Excel adds that value to 1900 to calculate the year. For example, DATE(108,1,2) returns January 2, 2008 (1900+108).
  • If year is between 1900 and 9999 (inclusive), Excel uses that value as the year. For example, DATE(2008,1,2) returns January 2, 2008.
  • If year is less than 0 or is 10000 or greater, Excel returns the #NUM! error value.

ShowHow does Excel for the Macintosh work with the 1904 date system?

  • If year is between 4 and 1899 (inclusive), Excel adds that value to 1900 to calculate the year. For example, DATE(108,1,2) returns January 2, 2008 (1900+108).
  • If year is between 1904 and 9999 (inclusive), Excel uses that value as the year. For example, DATE(2008,1,2) returns January 2, 2008.
  • If year is less than 4 or is 10000 or greater or if year is between 1900 and 1903 (inclusive), Excel returns the #NUM! error value.
  • month    Required. A positive or negative integer representing the month of the year from 1 to 12 (January to December).
    • If month is greater than 12, month adds that number of months to the first month in the year specified. For example, DATE(2008,14,2) returns the serial number representing February 2, 2009.
    • If month is less than 1, month subtracts the magnitude of that number of months, plus 1, from the first month in the year specified. For example, DATE(2008,-3,2) returns the serial number representing September 2, 2007.
  • day    Required. A positive or negative integer representing the day of the month from 1 to 31.
    • If day is greater than the number of days in the month specified, day adds that number of days to the first day in the month. For example, DATE(2008,1,35) returns the serial number representing February 4, 2008.
    • If day is less than 1, day subtracts the magnitude that number of days, plus one, from the first day of the month specified. For example, DATE(2008,1,-15) returns the serial number representing December 16, 2007.

 Notes 

 Note   Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900. Microsoft Excel for the Macintosh uses a different date system as its default.

For more information, see Change the date system, format, or two-digit year interpretation.

Example

The example may be easier to understand if you copy it to a blank worksheet.

ShowHow do I copy an example?

  1. Select the example in this article. If you are copying the example in Excel Web App, copy and paste one cell at a time.Important Do not select the row or column headers.

Selecting an example from Help

Selecting an example from Help

  1. Press CTRL+C.
  2. Create a blank workbook or worksheet.
  3. In the worksheet, select cell A1, and press CTRL+V. If you are working in Excel Web App, repeat copying and pasting for each cell in the example.

Important For the example to work properly, you must paste it into cell A1 of the worksheet.

  1. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

After you copy the example to a blank worksheet, you can adapt it to suit your needs.


 
1
2
3
4
5




6




7



8
A B C
Year Month Day
2008 1 1
Data
20081125
Formula Description Result
=DATE(A2,B2,C2) Serial date for the date derived by using cells A2, B2, and C2 as the arguments for the DATE function, and using the 1900 date system. 1/1/2008 or 39448
=DATE(YEAR(TODAY()),12,31) Serial date for the last day of the current year. 12/31/nnnn or the equivalent sequential serial number (actual value depends on current year)
=DATE(LEFT(A4,4),MID(A4,5,2), RIGHT(A4,2)) A formula that converts a date from the YYYYMMDD format to a serial date. 11/25/2008 or 39777

 Note   To view the number as a serial number, select the cell and then, on the Sheet tab, in the Number group, click the arrow next to Number Format, and then click Number.

 
 
Applies to:
Excel 2007