Use Date Formula in Excel
In this video Guru teaches how to use the data formula to get a date in a single cell from data mentioned in separate columns.
The DATE function returns the sequential serial number that represents a particular date.
The DATE function syntax has the following arguments:
- Year Required. The value of the year argument can include one to four digits. Excel interprets the yearargument according to the date system your computer is using. By default, Microsoft Excel for Windows uses the 1900 date system, which means the first date is January 1, 1900.
Tip: Use four digits for the year argument to prevent unwanted results. For example, “07” could mean “1907” or “2007.” Four digit years prevent confusion.
- 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.
- 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.
Note: Excel stores dates as sequential serial numbers so that they can be used in calculations. 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. You will need to change the number format (Format Cells) in order to display a proper date.
For example: =DATE(C2,A2,B2) combines the year from cell C2, the month from cell A2, and the day from cell B2 and puts them into one cell as a date. The example below shows the final result in cell D2.
- Right-click the cell(s) you want to change. On a Mac, Ctrl-click the cells.
- On the Home tab click Format > Format Cells or press Ctrl+1 (Command+1 on a Mac).
- 3. Choose the Locale (location) and Date format you want.
- For more information on formatting dates, see Format a date the way you want.
You can use the DATE function to create a date that is based on another cell’s date. For example, you can use the YEAR, MONTH, and DAY functions to create an anniversary date that’s based on another cell. Let’s say an employee’s first day at work is 10/1/2016; the DATE function can be used to establish his fifth year anniversary date:
- The DATE function creates a date.
- The YEAR function looks at cell C2 and extracts “2012”.
- Then, “+5” adds 5 years, and establishes “2017” as the anniversary year in cell D2.
- The MONTH function extracts the “3” from C2. This establishes “3” as the month in cell D2.
- The DAY function extracts “14” from C2. This establishes “14” as the day in cell D2.
If you open a file that came from another program, Excel will try to recognize dates within the data. But sometimes the dates aren’t recognizable. This is may be because the numbers don’t resemble a typical date, or because the data is formatted as text. If this is the case, you can use the DATE function to convert the information into dates. For example, in the following illustration, cell C2 contains a date that is in the format: YYYYMMDD. It is also formatted as text. To convert it into a date, the DATE function was used in conjunction with the LEFT, MID, and RIGHT functions.
- The DATE function creates a date.
- The LEFT function looks at cell C2 and takes the first 4 characters from the left. This establishes “2014” as the year of the converted date in cell D2.
- The MID function looks at cell C2. It starts at the 5th character, and then takes 2 characters to the right. This establishes “03” as the month of the converted date in cell D2. Because the formatting of D2 set to Date, the “0” isn’t included in the final result.
- The RIGHT function looks at cell C2 and takes the first 2 characters starting from the very right and moving left. This establishes “14” as the day of the date in D2.
To increase or decrease a date by a certain number of days, simply add or subtract the number of days to the value or cell reference containing the date.
In the example below, cell A5 contains the date that we want to increase and decrease by 7 days (the value in C5).
For more such videos and to download the training file visit www.myelesson.org This Excel tutorial has been created to help you learn microsoft excel online. On http://www.myelesson.org you get excel help and online file download facitity. This video lesson covers the entire topic in simple and easy to understand step by step approach. ”