Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less
Use Excel’s DATE function when you need to take three separate values and combine them to form a date.
The DATE function returns the sequential serial number that represents a particular date.
Syntax: DATE(year,month,day)
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 year argument 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.
Syntax: DATE(year,month,day)
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.
Need to insert dates without a formula? No problem. You can insert the current date and time in a cell, or you can insert a date that gets updated. You can also fill data automatically in worksheet cells.
-
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.
=DATE(YEAR(C2)+5,MONTH(C2),DAY(C2))
-
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.
=DATE(LEFT(C2,4),MID(C2,5,2),RIGHT(C2,2))
-
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).
See Also
Add or subtract dates
Insert the current date and time in a cell
Fill data automatically in worksheet cells
YEAR function
MONTH function
DAY function
TODAY function
DATEVALUE function
Date and time functions (reference)
All Excel functions (by category)
All Excel functions (alphabetical)
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
Bottom line: With Valentine’s Day rapidly approaching I thought it would be good to explain how you can get a date with your Excel skills. Just kidding! 🙂 This post and video explain how the date calendar system works in Excel.
Skill level: Beginner
Dates in Excel can be just as complicated as your date for Valentine’s Day. We are going to stick with dates in Excel for this article because I’m not qualified to give any other type of dating advice. 🙂
Video Tutorial on How Dates Work in Excel
The following is a video from The Ultimate Lookup Formulas Course on how the date system works in Excel.
Watch the Video on YouTube
There are over 100 short videos just like the one above included in the Ultimate Lookup Formulas Course.
This course has been designed to help you master Excel’s most important functions and formulas in an easy step-by-step manner.
The Ultimate Lookup Formulas course is now part of our comprehensive Elevate Excel Training Program.
Click Here to Learn More About Elevate Excel
What is a Date in Excel?
I should first make it clear that I am referring to a date that is stored in a cell.
The dates in Excel are actually stored as numbers, and then formatted to display the date. The default date format for US dates is “m/d/yyyy” (1/27/2016).
The dates are referred to as serial numbers in Excel. You will see this in some of the date functions like DAY(), MONTH(), YEAR(), etc.
So then, what is a serial number? Well let’s start from the beginning.
The date calendar in Excel starts on January 1st, 1900. As far as Excel is concerned this day starts the beginning of time.
Each Day is a Whole Number
Each day is represented by one whole number in Excel. Type a 1 in any cell and then format it as a date. You will get 1/1/1900. The first day of the calendar system.
Type a 2 in a cell and format it as a date. You will get 1/2/1900, or January 2nd. This means that one whole day is represented by one whole number is Excel.
You can also take a cell that contains a date and format it as a number.
For example, this post was published on 1/27/2016. Put that number in a cell (the keyboard shortcut to enter today’s date is Ctrl+;), and then format it as a number or General.
You will see the number 42,396. This is the number of days that have elapsed since 1/1/1900.
Date Based Calculations
It is important to know that dates are stored as the number of days that have elapsed since the beginning of Excel’s calendar system (1/1/1900).
When you calculate the difference between two dates by subtraction, the result will be the number of days between the two dates.
1/27/2016 – 1/1/2016 = 26 days
6/30/2016 – 1/1/2016 = 181 days
There are a lot of Date functions in Excel that can help with these calculations. Last week we learned about the DAY function for month-to-date calculations with pivot tables.
We won’t go into all the date functions here, but understanding that the serial number represents one day will give you a good foundation for working with dates.
What About Dates with Times?
Do you ever work with dates that contain time values?
These dates are still stored as serial numbers in Excel. When you convert the date with a time to the number format, you will see a decimal number.
This decimal is a fraction of the day.
One hour in Excel is represented by the number: 1/24 = 0.04167
One minute in Excel is represented by the number: 1/(24*60) = 1/1440 = 0.000694
So 8:30 AM can be calculated as: (8 * (1/24)) + (30 * (1/1440)) = .354167
An easier way to calculate this is by typing 8:30 AM in a cell, then changing the format to Number.
So if you are running a half hour late and want to let your boss know, text him/her and say you will be there at 0.354167. 🙂
Checkout my article on 3 ways to group times in Excel for more date time based calculations.
Don’t Talk About Excel Dates with Your Date
Unless your Valentine shares a similar passion for Excel, I strongly recommend NOT sharing this information on your date.
I remember the first time I met my wife, and told her I worked in finance. The first word out of her mouth was, “BORING!”. Awe… it was love at first sight… LOL 🙂
But you should now be able to use Excel to determine how many days it has been since you last spoke to your date. That’s the only dating advice I can give.
Please leave a comment below with any questions on Excel dates. Thanks!
How to Use Excel > Excel Functions > Excel YEAR Function
How to Use Excel YEAR Function
Table of contents :
- What is the Excel YEAR Function?
- YEAR Syntax
- How to Use YEAR Function in Excel
- YEAR Example
What is the Excel YEAR Function?
The Excel YEAR function returns the year corresponding to date as a 4-digit number starting from 1900 until 9999. Use the YEAR function to extract the year from a date into a cell.
YEAR Syntax
YEAR(serial_number)
serial_number, required, a valid Excel date from which to extract the year.
Usage Note:
- Excel only accepts dates from January 1, 1900, to December 31, 9999, any date outside the range causes Excel to return a #VALUE error.
How to Use YEAR Function in Excel
Pay attention to the data in column A; there are seven dates with various display formats. Column B contains the YEAR function, extracts the year number from the date. The results are in accordance with the date entered except the last two dates. Why? Let’s look at one by one.
YEAR Function #1 – YEAR Function #5
There are many formats for displaying a date, but a valid excel date format must comply with the Windows regional settings on each computer.
To find out the valid Excel date format, look at the formula bar. The date in the second row until the sixth row has the same valid excel date format mm/dd/yyyy, even though the format of the display varies.
The result is the YEAR function #1 until the YEAR function #5 returns the correct numbers.
YEAR Function #6
The YEAR function on the seventh row returns a #VALUE! error, because a valid excel date format does not match the Windows regional settings format.
Please look at the formula bar; the date is a text. The display format is the same as the date on the second row, but the actual data is text. Note the quotation marks at the beginning; it is also a sign that the data on the seventh row is a text, not a date.
YEAR Function #7
Date in eight row matches to the valid excel date format; the problem is the date entered is less than January 1, 1900. Excel will consider it a text and returns the same error as the date in the previous row.
YEAR Example
Another article using or explain about YEAR Function
Another Date/Time Function
Another article about Date/Time Function
What is a date in Excel?
A date is a number! And like any number (currency, percentage, decimal, …), you can customize your date format 👍
Dates are whole numbers
Usually, when you insert a date in a cell it is displayed in the format dd/mm/yyyy or mm/dd/yyyy.
Let’s say you have the date 01/01/2016 in a cell. If you change the cell’s format to Standard, the cell displays 42370 😕🤔
Explanation of the numbering
In Excel, a date is the number of days since 01/01/1900 (the first date in Excel).
So 42370 is the number of days between 01/01/1900 and 01/01/2016.
Date format
Dates can be displayed in different ways using the following 2 options (available in the Number Format dropdown in the main menu):
- Short Date
- Long Date
How to customize a date?
To customize a date:
- Open the dialog box Custom Number (with the shortcut Ctrl + 1 or by clicking on the menu More number formats at the bottom of the number format dropdown)
- In this dialog box, you select ‘Custom‘ in the Category list and write the date format code in ‘Type‘.
To format a date, you just write the parameter d, m or y a different number of times. For example,
- dd/mm/yyyy will display 01/01/2016
- dd mmm yyyy => 01 Jan 2016
- mmmm yyyy => January 2016
- dddd dd => Friday 01
In function of your language , the letter could be different:
- t for «tag» (day) in German
- j for «jour» (day) in French
- a for «año» (year) in Spanish
Don’t write text in your cell !!!
With dates, one of the most common mistakes is to write text inside the format code (1 January 2016 for example). Never do this in Excel ⛔⛔⛔
If you do this, the contents of the cell will be Text and not a number
- In Excel, text is always displayed on the left of a cell.
- A number or a date is displayed on the right.
If you want to display the month in letters, just change the month format of your date.
Different examples of custom date
The following document shows you the same date but in different formats. The code for each date is in column A.
Different writing of dates according to the format code
In the following document, you can see the impact of each format on the same date.
Date and time in excel are treated a bit differently in excel than in other spreadsheets software. If you don’t know how Excel date and time work, you may face unnecessary errors.
So, in this article, we will learn everything about the date and time of Excel. We will learn, what are dates in excel, how to add time in excel, how to format date and time in excel, what are date and time functions in excel, how to do date and time calculations (adding, subtracting, multiplying etc. with dates and times).
What is Date and Time in Excel?
Many of you may already know that Excel dates and time are nothing but serial numbers. A date is a whole number and time is a fractional number. Dates in excel have different regional formatting. For example, in my system, it is mm/dd/YYYY (we will use this format throughout the article). You may be using the same date format or you could be using dd/mm/YYYY date format.
Date Formatting of Cell
There are multiple options available to format a date in Excel. Select a cell that may contain a date and press CTRL+1. This will open the Format Cells dialogue box. Here you can see two formatting options as Date and Time. In these categories, there are multiple date formattings available to suit your requirements.
Dates:
Dates in Excel are mare serial numbers starting from 1-Jan-1900. A day in excel is equal to 1. Hence 1-Jan-1900 is 1, 2-Jan-1900 is 2, and 1-Jan-2000 is 36526.
Fun Fact: 1900 was not a leap year but excel accepts 29-Feb-1900 as a valid date. It was a desperate glitch to compete Lotus 1-2-3 back in those days.
Shortcut to enter static today’s date in excel is CTRL+; (Semicolon).
To add or subtract a day from a date you just need to subtract or add that number of days to that date.
Time:
Excel by default follows the hh:mm format for time (0 to 23 format). The hours and minutes are separated by a colon without any spaces in between. You can change it to hh:mm AM/PM format. The AM/PM must have 1 space from the time value. To include seconds, you can add :ss to hh:mm (hh:mm:ss). Any other time format is invalid.
Time is always associated with a date. The date comes before the time value separated with a space from time. If you don’t mention a date before time, by default it takes the first date of excel (which is 1/1/1900). Time in excel is a fractional number. It is shown on the right side of the decimal.
Hours:
Since 1 day is equal to 1 in excel and 1 day consists of 24 hours, 1 hour is equal to 1/24 in excel. What does that mean? It means that if you want to add or subtract 1 hour to time, you need to add or subtract 1/24. See the image below.
you can say that 1 hour is equal to 0.041666667 (1/24).
Calculate hours between time in Excel
Minutes:
From the explanation of the hour in excel, you must have guessed that 1 Minute in excel is equal to 1/(24×60) (or 1/1440 or 0.000694444).
If you want to add a minute to an excel time, add 1/(24×60). See the image below. Sometimes you get the need to Calculate Minutes Between Dates & Time In Excel, you can read it here.
Seconds:
Yes, a second in Excel is equal to 1/(24x60x60). To add or subtract seconds from a time, you just need to do the same things as we did in minutes and hours.
Date and Time in one cell
Dates and times are linked together. A date is always associated with a valid date and time is always associated with a valid excel date. Even if you are not able to see one of them.
If you only enter a time in a cell, the date of that cell will 1-Jan-1900, even if you are not able to see it. If you format that cell as a date-time format, you can see the associated date. Similarly, if you don’t mention time with the date, by default 12:00 AM is attached. See the image below.
In the image above, we have time only in B3 and date only in B4. When we format these cells as mm/dd/yy hh:mm, we get both, time and date in both cells.
So, while doing date and time calculations in excel, keep this in check.
No Negative Time
As I told you the date and time in excel starts from 1-Jan-1900 12:00 AM. Any time before this is not a valid date in excel. If you subtract a value from a date that leads to before 1-Jan-1900 12:00, even one second, excel will produce ###### error. I have talked about it here and in Convert Date and Time from GMT to CST. It happens when we try to subtract something that leads to before 1 Jan-1900 12:00. Try it yourself. Write 12:00 PM and subtract 13 hours from it. see what you get.
Calculations with Dates and Time in Excel
Adding Days to a date:
Adding days to a date in excel is easy. To add a day to date just add 1 to it. See the image below.
You should not add two dates to get the future date, as it will sum up the serial numbers of those days and you may get a date far in the future.
Subtracting Days from Date:
If you want to get a backdate from a date a few days before, then just subtract that number of days from the date and you will get backdate. For example, if I want to know what date was before 56 days since TODAY then I would write this formula in the cell.
This will return us the date of 56 before the current date.
Note: Remember that you can not have a date before 1/Jan/1900 in excel. If you get ###### error, this could be the reason.
Days between two dates:
To calculate days between two dates we just need to subtract the start date from the end date. I have already done an article on this topic. Go and check it out here. You can also use the Excel DAYS Function to calculate days between a start date and end date.
Adding Times:
There’s been a lot of queries on how to add time to excel as many people get confusing results when they do it. There are two types of addition in times. One is adding time to another time. In this case, both times are formatted as hh:mm time format. In this case, you can simply add these times.
The second case is when you don’t have additional time in time format. You just have numbers of hours, minutes and seconds to add. In that case, you need to convert those numbers to their time equivalents. Note these points to add hours, minutes and seconds to a date/time.
- To add N hours to an X time use formula =X+(N/24) (As 1=24 hours)
- To Add N minutes to X time use formula = X+(N/(24*60))
- To Add N Second to X time use formula = X+(N/(24*60*60))
Subtracting Times
It’s the same as adding time, just make sure that you don’t end up with a negative time value when subtracting, because there is no such thing as a negative number in excel.
Note: When you add or subtract time in excel that exceeds 24 hours of difference, excel will roll to the next or previous date. For example, if you subtract 2 hours from 29-Jan-2019 1:00 AM then it will roll back to 28-Jan-2019 11:00 PM. If you subtract 2 hours from 1:00 AM (does not have the date mentioned), Excel will return ###### error. I have told the reason at the beginning of the article.
Adding Months to a Date:
You can’t just add multiples of 30 to add months to date as different months have a different number of days. You need to be careful while adding months to Date. To add months to a date in excel, we use EDATE function of excel. Here I have a separate article on adding months to a date in different scenarios.
Adding years to date:
Just like adding months to a date, it is not straightforward to add years to date. We need to use YEAR, MONTH, DAY function to add years to date. You can read about adding years to date here.
If you want to calculate years between dates then you can use this.
Excel Date and Time Handling Functions:
Since date and time are special in Excel, Excel provides special functions to handle them. Here I am mentioning a few of them.
- TODAY(): This function returns today’s date dynamically.
- DAY(): Returns Day of the month (returns number 1 to 31).
- DAYS(): Used to count the number of days between two dates.
- MONTH(): Used to get the month of the date (returns number 1 to 12).
- YEAR(): Returns year of the date.
- WEEKNUM(): Returns the weekly number of a date, in a year.
- WEEKDAY(): Returns the day number in a week (1 to 7) of the supplied date.
- WORKDAY(): Used to calculate working days.
- TIMEVALUE(): Used to extract Time value (serial number) from a text formatted date and time.
- DATEVALUE(): Used to extract date value (serial number) from a text formatted date and time.
These are some of the most useful data and time functions in excel. There are plenty more date and time functions. You can check them out here.
Date and Time Calculations
If I explain all of them here, this article will get too long. I have divided these time calculation techniques in excel into separate articles. Here I am mentioning them. You can click on them to read.
- Calculate days, months and years
- Calculate age from date of birth
- Multiplying time values and numbers.
- Get Month name from Date in Excel
- Get day name from Date in Excel
- How to get a quarter of the year from date
- How to Add Business Days in Excel
- Insert Date Time Stamp with VBA
So yeah guys, this is all about the date and time in excel you need to know about. I hope this article was useful to you. If you have any queries or suggestions, write them down in the comments section below.