Add or subtract days from a date
Suppose that a bill of yours is due on the second Friday of each month. You want to transfer funds to your checking account so that those funds arrive 15 calendar days before that date, so you’ll subtract 15 days from the due date. In the following example, you’ll see how to add and subtract dates by entering positive or negative numbers.
-
Enter your due dates in column A.
-
Enter the number of days to add or subtract in column B. You can enter a negative number to subtract days from your start date, and a positive number to add to your date.
-
In cell C2, enter =A2+B2, and copy down as needed.
Add or subtract months from a date with the EDATE function
You can use the EDATE function to quickly add or subtract months from a date.
The EDATE function requires two arguments: the start date and the number of months that you want to add or subtract. To subtract months, enter a negative number as the second argument. For example, =EDATE(«9/15/19»,-5) returns 4/15/19.
-
For this example, you can enter your starting dates in column A.
-
Enter the number of months to add or subtract in column B. To indicate if a month should be subtracted, you can enter a minus sign (-) before the number (e.g. -1).
-
Enter =EDATE(A2,B2) in cell C2, and copy down as needed.
Notes:
-
Depending on the format of the cells that contain the formulas that you entered, Excel might display the results as serial numbers. For example, 8-Feb-2019 might be displayed as 43504.
-
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, 2010 is serial number 40179 because it is 40,178 days after January 1, 1900.
-
If your results appear as serial numbers, select the cells in question and continue with the following steps:
-
Press Ctrl+1 to launch the Format Cells dialog, and click the Number tab.
-
Under Category, click Date, select the date format you want, and then click OK. The value in each of the cells should appear as a date instead of a serial number.
-
-
Add or subtract years from a date
In this example, we’re adding and subtracting years from a starting date with the following formula:
=DATE(YEAR(A2)+B2,MONTH(A2),DAY(A2))
How the formula works:
-
The YEAR function looks at the date in cell A2, and returns 2019. It then adds 3 years from cell B2, resulting in 2022.
-
The MONTH and DAY functions only return the original values from cell A2, but the DATE function requires them.
-
Finally, the DATE function then combines these three values into a date that’s 3 years in the future — 02/08/22.
Add or subtract a combination of days, months, and years to/from a date
In this example, we’re adding and subtracting years, months and days from a starting date with the following formula:
=DATE(YEAR(A2)+B2,MONTH(A2)+C2,DAY(A2)+D2)
How the formula works:
-
The YEAR function looks at the date in cell A2, and returns 2019. It then adds 1 year from cell B2, resulting in 2020.
-
The MONTH function returns 6, then adds 7 to it from cell C2. This gets interesting, because 6 + 7 = 13, which is 1-year and 1-month. In this case, the formula will recognize that and automatically add another year to the result, bumping it from 2020 to 2021.
-
The DAY function returns 8, and adds 15 to it. This will work similarly to the MONTH portion of the formula if you go over the number of days in a given month.
-
The DATE function then combines these three values into a date that is 1 year, 7 months, and 15 days in the future — 01/23/21.
Here are some ways you could use a formula or worksheet functions that work with dates to do things like, finding the impact to a project’s schedule if you add two weeks, or time needed to complete a task.
Let’s say your account has a 30-day billing cycle, and you want to have the funds in your account 15 days before the March 2013 billing date. Here’s how you would do that, using a formula or function to work with dates.
-
In cell A1, type 2/8/13.
-
In cell B1, type =A1-15.
-
In cell C1, type =A1+30.
-
In cell D1, type =C1-15.
Add months to a date
We’ll use the EDATE function and you’ll need the start date and the number of months you want to add. Here’s how to add 16 months to 10/24/13:
-
In cell A1, type 10/24/13.
-
In cell B1, type =EDATE(A1,16).
-
To format your results as dates, select cell B1. Click the arrow next to Number Format, > Short Date.
Subtract months from a date
We’ll use the same EDATE function to subtract months from a date.
Type a date in Cell A1 and in cell B1, type the formula =EDATE(4/15/2013,-5).
Here, we’re specifying the value of the start date entering a date enclosed in quotation marks.
You can also just refer to a cell that contains a date value or by using the formula =EDATE(A1,-5)for the same result.
More examples
To add years to or subtract years from a date
Start Date |
Years added or subtracted |
Formula |
Result |
---|---|---|---|
10/24/2013 |
3 (add 3 years) |
=DATE(YEAR(A2)+B2,MONTH(A2),DAY(A2)) |
10/24/2016 |
10/24/2013 |
-5 (subtract 5 years) |
=DATE(YEAR(A4)+B4,MONTH(A4),DAY(A4)) |
10/24/2008 |
Today, I am going to equip you with a few formulas that will enable you to add Days (Months or even Years) to a Date in Excel.
These are particularly useful for financial analysts because it helps them play around with and manipulate time periods in their financial models. For example, while projecting cash flows, you may want to project them monthly, quarterly, semi-annually, or annually. All you have to do then is use these formulas and add 1, 3, 5, or 11 to your dates, and you are set.
With that foundation, let’s jump in.
Add Days to a Date in Excel
We all know that Excel stores dates as serial numbers. There is no magical formula that Excel uses to assign serial numbers to dates, though. The serial numbers are assigned such that January 1, 1900 is considered as 1, and thereafter the numbers increment with each day. Based on the same logic, Dec 25, 2001, corresponds to 37,250 because it is 37,249 days after January 1, 1900.
Just for this reason, when you want to add a certain number of days to a date in Excel, you can just put in the number of days you want to add and you will have your output date.
We will use the following formula (which is actually just plain addition) to add 31 days to a date:
=A2 + 31
Excel will add 31 days to 12/25/2001 (or 37250 as a serial number) and arrive at the serial number 37281, i.e. the serial number for 01/25/2002.
Recommended Reading: How to add Days to Date In Excel
Add Months to a Date in Excel
To add months to a given date in your worksheet, we will use the EDATE function.
Syntax for the EDATE function:
=EDATE(start_date, number_of_months)
Arguments:
start_date
: This is a required argument where you will refer to a cell containing the date.number_of_months
: This is a required argument where you may enter a number or refer to a cell containing the number of months you want to add to the date.
In our example, we will try to add 2 months to a date and for that, we will use the formula:
=EDATE(A2, 2)
Instead of writing ‘2’ in the number of months argument, we could just as well refer to a cell containing the number 2. Also, ensure that the output cell is formatted to display a date.
Recommended Reading: How to add Months to Date In Excel
Add Years to a Date in Excel
We will use the DATE function for adding years to a date in Excel. If you are not familiar with the DATE function, go check out our tutorial on the DATE function. Along with the DATE function, we will also use the YEAR, MONTH, and DAY functions.
Alright, so this is the formula we are going to use to add 5 years to a given date:
=DATE(YEAR(A2) + 5,MONTH(A2),DAY(A2))
Notice the +5 tucked away in the first argument? That is the number of years we want to add to our date. Alternatively, you could also reference a cell containing the number ‘5.’
The YEAR, MONTH, and DAY functions have a small role to play here. All they do is derive a specific component of a date. All these functions are nested into the DATE function. So, upon deriving their respective values, they will supply those values to DATE function as an argument.
In our case, here is what each function will derive:
- YEAR(A2): 2001
- MONTH(A2): 12
- DAY(A2): 25
So, our DATE function at this point looks like this:
=DATE(2001 + 5, 12, 25)
Looks pretty simple now, right?
The DATE function will then just add 5 to 2001 and give us the final output as 12/25/2006.
Recommended Reading: How to add Years to Date In Excel
Add Working Days to a Date in Excel
Now, onto some interesting formulas. Let’s say we want to add days to a given date. But, we would like Excel to skip over the weekends and holidays.
To accomplish this, we will use the WORKDAY function in Excel. This function will skip over weekends (Saturday and Sunday) by default, but you will need to supply a list of holidays (if any) as an argument in the WORKDAY function.
Syntax for the WORKDAY function:
=WORKDAY(start_date, add_days, holidays)
Arguments:
start_date
: This is a required argument where you will refer to a cell containing the date.sdd_days
: This is a required argument where you may enter a number or refer to a cell containing the number of days you want to add to the date.holidays
: This is an optional argument where you may supply a list of holidays by referencing a range of cells that contain the list of holidays.
The formula we will use in our example is:
=WORKDAY(A2, 60, D2:D4)
What we are doing in this example is trying to compute the date that falls 60 working days after 12/25/2001, provided that there is 1 holiday in December 2001, and 2 in January 2002.
Notice that we supplied the list of holidays separately, while the weekends were factored in by the formula by default.
The return we get is 03/21/2002, which is the date that falls 60 working days after 12/25/2001.
The formula also works if you want to compute working days in reverse and arrive at a date that falls a certain number of days before 12/25/2001. For example, entering -60 instead of 60 in the add_days argument will return 10/02/2001.
Add Hours, Minutes, or Seconds to a DateTime in Excel
We are now ready to take on some larger formulas. Let’s try to play around with some DateTimes and see how we can manipulate them.
Add Hours to a DateTime in Excel
In this example, we will use 3 functions to build a formula for adding 30 hours to a DateTime. The functions that we are going to use are – TIME, MOD, and INT.
The formula would be:
=TIME(MOD(30, 24), 0, 0) + A2 + INT(30/24)
Okay, let’s disassemble this formula one function at a time.
We will start with the simple ones first. Cell A2 is just the starting date that we want to add the hours to.
Refer to our example #1 and see how all it takes to add days to a date in Excel is a ‘+’ and the number of days. That is what the INT function is doing here. If the hours exceed 24, it will add a day to the date so our final output is adjusted accordingly. This means that if you are adding less than 24 hours, this component will not have any effect on the formula because it will return 0.
With the TIME function, we are instructing Excel to add a certain number of hours to the time in cell A2. The second and third arguments are ‘0’ because we do not wish to add any minutes or seconds to the time just yet.
The first argument is where we enter the number of hours, but we will use a MOD function to compute the number of hours to be added.
MOD function gives us the remainder from a certain division. In our case, we divide 30 by 24, which gives us 6. If you had slept through your Class 12 Maths class, just think of it like this (if you know how modulus works, feel free to skip to the next part):
- When the number of hours to be added is below 24, the MOD function returns the same number (if the number were 15, MOD would return 15).
- When the number of hours to be added is 24, the MOD function returns 0.
- When the number of hours to be added (X) is more than 24 but less than 48, the MOD function returns (X – 24).
- The MOD function will return 0 again if you add 48 hours, and beyond 48 hours, it will continue to deliver an outcome like so: (X – 48). At 48, 72, 96 hours (i.e., after every 24 hours), the MOD function will return a 0, and beyond those numbers, the MOD function will return: (X – relevant multiple of 24).
If you find it difficult to wrap your head around, just read the first 3 points, and that will suffice.
Okay, so we have come a long way in dismantling this formula. Let’s take stock of where we stand:
=TIME(6, 0, 0) + A2 + 1
We know the MOD function will return a ‘6,’ and we know the INT function will return a ‘1.’
Essentially, we have now asked Excel to pick up the DateTime in cell A2, add 1 day to it (via the INT function), and add 6 hours (via the TIME and MOD function).
The final output, of course, is 12/26/2001 6:00:00 AM.
Add Minutes to a DateTime in Excel
Let’s now try to add 2500 minutes to a DateTime in Excel. A lot of what we discussed in the previous example remains unchanged here. So, we will first look at what needs to be done differently.
Point of difference #1: The most basic difference in our next formula will be the denominators used. In the previous example, we used 24 since we wanted to convert days to hours. This time around, we will use 1440 as our denominator to convert days into minutes since there are 1440 minutes in a day.
Point of difference #2: The second difference is that instead of 1, we will use 2 INT functions in the next formula.
Point of difference #3: We will also use 2 MOD functions instead of 1.
Why the difference?
Let’s circle back to the “why” after setting up our example.
Here is the formula we will use:
=TIME(INT(MOD(2500, 1440)/60), MOD(2500, 60), 0) + A2 + INT(2500/1440)
Let’s nail the easy ones first. We know cell A2 is the date we want to add minutes to. The INT function at the tail of the formula returns 1 (because we need to add 1 day) since the number of minutes we are adding exceeds 1440 but does not exceed 2880.
Alright, so the complexity is tucked inside the 3 arguments of the TIME function. Since we now know what the TIME function does, let’s jump onto the role these arguments play in there.
The first argument has, in total, 3 operations and 2 functions.
The first operation is the computation of the MOD function. We know the pattern that the output of the MOD function follows, right? So, the MOD function will give us 1060 (or 2500 – 1440).
The second operation is the division of the MOD function’s output by 60. So, why is there a 60 in the formula? Well, when the MOD function gives us 1060, it is trying to tell us that you need to add these many minutes to your DateTime to get the final output. To convert it to hours, we divide it by 60, which gives us ~ 17.67 hours.
Perfect. What if I tell you I will be 3.5 hours late today? You will interpret it as 3 hours and 30 minutes, right?
That is precisely what the INT function is there for in the first argument. Any time you see hours being written with a decimal, it is interpreted as minutes. But remember, we cannot have minutes in the hours’ argument of the TIME function, so we must remove it by eliminating the value after the decimal using the INT function. Finally, the hours’ argument has the value ‘17.’
The second argument has just one operation and one function.
In the second argument, we need the number of minutes that need to be added to our final output. To do this, we will use another MOD function.
No other complexities, though (or maybe give it 10 seconds). Just the good ol’ MOD function with dividend as 2500 and the divisor as 60. Right?
Wait, why 60?
In the previous argument, we used the INT function to remove the minutes component from the return. So, we are going to transfer it to this argument because this is where minutes belong.
If this is difficult to understand, let me reverse engineer it for you. Remember how in the previous argument, we used the INT function to remove .67 after the 17 hours? Those 0.67 hours are what we are trying to add here. 0.67 (or 2/3rd) hours is 40 minutes.
Guess what MOD (2500, 60) gives us?
40!
The third argument is 0, at least for now.
This is what our formula looks like at this point:
=TIME(17, 40, 0) + A2 + 1
Looks pretty simple now, right? Essentially, the formula will add 1 day, 17 hours, and 40 minutes to 12/25/2001 12:00:00 AM and gives us our final output as 12/26/2001 5:40:00 PM.
Add Seconds to a DateTime in Excel
Now, let’s take a step further and try to add 90000 seconds to the given date. The formula remains the same across all three scenarios for adding hours, minutes, or seconds—with just some logical tweaking involved.
We will use the same formula we used previously, with slight modification, like so:
=TIME(INT(MOD(90000, 86400)/3600), INT(MOD(90000, 3600)), MOD(90000, 60)) + A2 + INT(90000/86400)
I know the formula looks as big as the Everest, but let’s take it one step at a time.
Our objective is to add 90,000 seconds to the DateTime given in cell A2. The logic for the formula remains the same, except for the arguments in the TIME function.
The hours argument
As always, we want this argument to end up with a value that is in terms of hours.
The MOD function in the hours argument will return 3600 (90,000 – 86400). In other words, we must add 3600 seconds to the time component of our DateTime to get our final output. However, to convert 3600 seconds to hours, we must divide it by the number of seconds in an hour, like so:
$$3600 seconds over [(3600 seconds)/(1 hour)]$$
OR
$$3600 seconds times [(1 hour)/(3600 seconds)]$$
This gives us 1 hour in the hours argument.
The minutes argument
Recollect how we tackled the second argument in the previous example where we had eliminated 0.67 hours from the first argument since this value actually represents minutes and should go in the second argument?
Well, this time around, our hours argument has returned just 1 hour—no decimals. This means we need to add nothing in the minutes argument.
If you check, the MOD function in the second argument will return a 0. If this baffles you, scroll back up and read the four pointers where we discussed how to compute the output for a MOD function. Basically, since 90,000 is perfectly divisible by 3600, it returns 0.
The seconds argument
Again, since we have just 1 full hour in the first argument and have no seconds component, the MOD function here will return a 0.
Add Hours, Minutes, or Seconds to a Time in Excel
After the extensive examples we have discussed thus far, this may feel like child’s play. But, let’s quickly run through some examples.
Add Hours to a Time in Excel
By now, you may be a TIME function ninja. So, see if you can figure out the formula before you look at it.
The formula we will use here:
=TIME(1, 0, 0) + A2
All we are doing here is instructing Excel that we want to add 1 hour (via the TIME function) to the Time in cell A2.
Add Minutes to a Time in Excel
We will use the same formula, but set the minutes argument to a certain number instead of 0 to add that many minutes, like so:
=TIME(1, 20, 0) + A2
This time around, we are adding 1 hour and 20 minutes to the TIME in cell A2.
Add Seconds to a Time in Excel
Again, no change:
=TIME(1, 20, 45) + A2
All we did differently this time is that we included the seconds argument, so Excel will add 1 hour, 20 minutes, and 45 seconds to the Time in cell A2.
That marks the end of our methods to add Dates, Time, and DateTime in Excel. Go ahead and use these formulas in your spreadsheet at work or just for fun. By the time you champion these, we will come back with another set of formulas for you to master.
In Microsoft Excel, the date can be inserted in a variety of ways, including using a built-in function formula or manually entering the date, such as 22/03/2021, 22-Mar-21, 22-Mar, or March 22, 2021. These date functions are typically used for cash flows in accounting and financial analysis.
In Excel, there is a built-in function called TODAY() that will insert the exact today’s date and will give the updated date whenever the workbook is opened. The NOW() built-in function can also be used to insert the current date and time, and this function will be kept up to date if we open the workbook multiple times.
Inserting the date:
In the Formula tab, the built-in TODAY is categorized under the DATE/TIME function.
Alternate to insert the date in Excel the below keyboard shortcut can be used:
CTRL+;
It will insert the current date.
To insert the current date and time we can use the following shortcut keys:
CTRL+; <space key> CTRL+SHIFT+;
It returns the current date and time to us.
1. Inserting specific date in Excel:
We have to use DATE() to insert a specific valid date in Excel. We can notice in the above function that the DATE requests to provide Year, Month, Day values. If we provide the details, the default date will be shown as below:
Image 1.1
Image 1.2
2. Inserting static date and time:
A static value in a sheet does not change if the sheet is recalculated or opened. To do so follow the below steps:
Step 1: Select the cell in which the current date or time will be inserted on a table.
Step 2: Do one of the next:
- Press Ctrl+;(semi-colon) to insert your current date.
- Press the Ctrl+Shift+;(semi-colon) to insert the current time.
- Press Ctrl+;(semi-column) to insert the current date and time then press Space, and press Ctrl+Shift+; (semi-colon).
Static date and time
3. Inserting a date in Excel via a drop-down calendar:
It may be a good idea to include a down calendar in your worksheet if you set up a table for other users and want to make sure that the dates enter correctly. You can fill in the dates with a mouse click and be 100% confident that all dates are entered in a suitable format. You can use Microsoft Date Picker control when you use a 32-bit version of Excel. Microsoft Date Picker Control will not work when you are using a 64-bit Excel 2016, Excel 2013 version.
4. Inserting an automatically updatable today’s date and current time:
If you want to keep your Excel date up-to-date today, use one of the following Excel date functions:
=TODAY() -> inserts in a cell the current date. =NOW() -> inserts in a cell the current and current date.
=TODAY example
=NOW example
Please remember that when using the Excel date functions:
- The date and the time returned will not be refreshed on an ongoing basis, but only when the chain is reopened or re-calculated.
- The functions take the current system clock date and time.
5. Auto-populate dates in Excel
To autofill a series of dates in which one day is incremented, you can use the Excel AutoFill function. It is a common way to automatically fill a column or row. To do so follow the below steps:
- Enter the original date in the first cell.
- Click the first date on your cell and then drag the fill handle to or from the cells you want Excel to add dates.
Autofill weekdays, months, or years:
There are two ways of automatically adding weekdays, months, or years to the selected range of cells. To so follow the below steps:
- You can use the above-mentioned Excel AutoFill options. Click the AutoFill Options icon and choose the option you want when the range is populated by sequential dates.
- Another way to enter your first date will be to right-click the fill handle and drag and release the fill handle through the cells you automatically want to fill with dates. Excel displays a context menu and selects the appropriate option.
Auto-populate dates
You may be knowing how easy it is to add or subtract numbers in Excel. Did you ever wonder how to add or subtract date and time in Microsoft Excel? Excel stores date and time as a serial numbers and uses in calculations. So if you understand how Excel treats date and time, it is easy for you to understand using them in calculations. In this article let us discuss how to use date and time functions and how to add or subtract date and time in Microsoft Excel.
Serialization of Date and Time Information in Excel
Excel uses two date systems – one is starting from 01 Jan 1900 and other is starting from 01 Jan 1904. Latest Excel versions, both on Windows and Mac, by default uses 1900 date system. We will explain all the functions with 1900 date system in this article. The process of calculations remains same even if you use 1904 date systems while the internal serialization of dates in Excel may change.
In 1900 date system, Excel starts the date from 01.01.1900 (01 Jan 1900) and assigns the serialization as 1. So the date 01.10.1900 (10 Jan 1900) will be converted to number 10 in Excel and 03.31.2018 (31 Mar 2018) will be serialized as 43190. Similarly time information is saved as decimal internally. For example, 0.5 indicates midday, 0.25 is 6AM and 0.75 is 6PM in Excel.
Now let us do a math for 31-Mar-2018 9:45AM. Open an Excel sheet and enter 31-Mar-2018 in one cell. Right click and choose “Format Cells…”. Under “Number” tab, select the date format (without time) for this cell. Enter 31-Mar-2018 09:45:00 AM in another cell and format this cell as date showing time. Now copy the two cells and paste in another row. Select both cells, right click and format them as plain numbers. You can choose no decimal for the first cell and 5 decimals for the second cell. It should look like below indicating 31-Mar-18 9:45 AM = 43190.40625 in Excel.
You can simply enter 43190.40625 in a cell and change the format to date with time. Excel will automatically convert the number into a date format with time as 31-Mar-18 9:45 AM. Remember, the number without any decimals is counted as 00:00:00 in time format. Only decimal is counted as time in Excel.
Calculations of Date and Time in Excel
Let us add some days to an existing date. For example, adding 10 days to 1/1/2018 should produce 1/11/2018. Enter 1/1/2018 in cell B3 and enter =10+B3 in cell B4 and press enter. You will see the result as 1/11/2018.
Just adding two dates may result in absolute addition in Excel which does not make sense. For example, when you add 1/31/18 and 3/1/18 will result in 4/2/36. But you can subtract two dates and show the difference of days in number format. For example, 3/1/18 – 1/31/18 will show the result as 29 days.
Similar to dates, you can add or subtract two cells in time format. Ensure you are always subtracting lower value from higher value and the format of the cells are in time. For example, 18:00 – 15:00 should result in 3:00.
Instead of working with cell reference, you can use direct date or time within double quotes for calculation like below:
=”12/24/2018″-“12/05/2018” (you will get 19 as result)
=”20:00″-“C9” (you will see 18:45 as result as cell C9 has the value 1:15)
Using NOW() and TODAY() for Calculations
You can also use two functions for date and time calculations. Now() is used to add or subtract time from the current time and Today() is used to add or subtract date from current date. Let us show some examples:
Ensure the cell is formatted as time format before using NOW() function and use the time for addition or subtraction within double quotes.
=NOW() will return the current time
=NOW()-“02:00” will subtract two hours from current time
=NOW()+”03:00″ will add three hours to current time
Ensure the cell is formatted as date format before using TODAY() function:
=TODAY() will return today’s date
=TODAY()-3 will subtract three days from today
=TODAY()+5 will add five days from today
Basic Date Functions
Microsoft Excel has the following date functions – TODAY(), YEAR(), MONTH(), DAY() and WEEKDAY(). The use case is shown as below. Enter =TODAY() function and press enter key on the cell C4. You can use all other functions with reference to the cell C4.
The WEEKDAY() function has an additional parameter return type. This is required to determine the first working day of the week. When you enter =WEEKDAY(C4,2) in the above example, you will get 1 as answer. This is because 2 indicates the week starts from Monday through Sunday. Hence, Monday on the reference cell is returned as 1 indicating it is first working day.
There is also DAYS() function that allows you to calculate the number of days between any two given dates. The syntax is =DAYS(end_date,start_date).
Basic Time Functions
Similar to date functions, Excel also supports different time functions – NOW(), HOUR(), MINUTE() and SECOND().
DATE and TIME Functions
DATE function is simply used to collect year, month and date from different reference cells and show it in a date format. Similarly TIME is function to concatenate hour, minutes and seconds from difference reference cells.
Using DATEDIF Function for Date Subtraction in Excel
Besides all those formal date and time functions, Excel also supports an informal function called DATEDIF. As per Microsoft support document, this function still works to support the older workbooks migrated to Excel from Lotus 1-2-3. But it can produce incorrect results in different situations, so not recommended to use.
DATEDIF function helps to calculate the number of years, months or dates between any given two dates. The syntax is as follows:
=DATEDIF(start date, end date,unit)
The unit value can be one of the followings:
- Y – number of complete years between the start and end dates.
- M – number of complete months
- D – number of days
- MD – number of days between the start and end dates, ignoring years and months. This value tend to produce incorrect results.
- YM – number of months between start and end dates, ignoring days and years.
- YD – number of days between two given dates, ignoring years.
Examples of Date Subtraction Using DATEDIF:
Note that DATEDIF being a supportive function for migration purposes, you will not see the formula help text appearing when entering the function in a cell. If you received an Excel workbook showing numbers in date column, then you can convert to proper dates using cell formatting.
In Excel, every valid date is stored as a form of the number. One important thing to be aware of in Excel is that we have a cut-off date of “31-Dec-1899”. Therefore, every date we insert in Excel will be counted from “01-Jan-1900 (including this date)” and stored as a number.
Table of contents
- How to Insert Date in Excel?
- Examples
- Example #1 – Date Stored as a Number
- Example #2 – Inserting Specific Date in Excel
- Example #3 – Changing the Inserted Date Format in Excel
- Example #4 – Insert List of Sequential Dates in Excel?
- Example #5 – Insert Dates with NOW() and TODAY() Excel Function
- Example #6 – How to Extract Selective Information from the Inserted Excel Date Values.
- Example #7 – Using TEXT() for Inserting Dates in Excel
- How to Change the Format of the Inserted Date in Excel?
- Things to Remember
- Recommended Articles
- Examples
Examples
Here, we will learn how to insert a date in Excel with the help of the examples below.
Example #1 – Date Stored as a Number
In the Excel sheet, let us take 50, 100, and today’s date, 30/01/2019.
Now, we can observe how data is stored in Excel when we change the formatting of the above data to date and accounting format.
50 – Change format to short date
100 – Change format to short date
30/01/2019 – Change format to accounting as it already in date format
If we observe the number 50 has been changed to date. It displayed exactly 50 days from 01/01/1900 (including this date in the count). Similarly, for the number 100, the date indicated in the exact count from 01/01/1900. And the third observation, which is already in date format and we changed to number format, displays “43,495.” So, today, 30/01/2019 is 43,495 days away from the cut-off date.
Example #2 – Inserting Specific Date in Excel
To insert a specific valid date in Excel, we must use DATE()The date function in excel is a date and time function representing the number provided as arguments in a date and time code. The result displayed is in date format, but the arguments are supplied as integers.read more.
In the above function, we can observe that DATE asks to provide “year,” “month,” and “day” values. As we give the details of it, then this displays the date in default format as below:
In the above example, we had given the “year” as 1992, “month” as 10, and “day” as 30. But, the output is displayed as per the default format.
Example #3 – Changing the Inserted Date Format in Excel
As seen in our earlier examples, we have displayed the date in a pre-defined format. To change the date format, we should go to “Format Cells.” Let us see how we can do it:
To access the “Format Cells,” we should right-click on the “Date” cell. Then, the above list of operations will pop out. Here, we must select the “Format Cells,” which may take us to the “Format Cells” window.
We got the list in a different format for the date as above. So, let us select one of the formats and see how the format got changed as below.
It is an important formatting feature that helps select dates as per their required format for different organizations.
Example #4 – Insert List of Sequential Dates in Excel?
If we want to list out of the sequential dates, we can select the start date, dragging it down until we reach the end date as per your requirement.
We must insert the date manually (do not use DATE()).
And drag it down as below.
Here we got the list of dates in a sequence from the starting date.
Example #5 – Insert Dates with NOW() and TODAY() Excel Function
To get the present-day date, we can use TODAY()Today function is a date and time function that is used to find out the current system date and time in excel. This function does not take any arguments and auto-updates anytime the worksheet is reopened. This function just reflects the current system date, not the time.read more and get the present day and the current time. Then, we should go with the NOW() FunctionIn an excel worksheet, the NOW function is used to display the current system date and time. The syntax for using this function is quite simple =NOW ().read more. Let us see the example below:
We also got a keyboard shortcut instead of the formulas.
We should use the “Alt +” shortcut instead of the TODAY() Excel function to get the present date.
We should use the “Alt + Shift + ” shortcut instead of the NOW() Excel function to get the present date along with the time.
There are three important functions in Excel that help us extract the specific information from the date. They are:
- DAY()In Excel, the DAY function calculates the day value from a given date. This function accepts a date as an argument and returns a two-digit numeric value as an integer value representing the given date’s day. The formula to use this function is =Edate(serial number).read more
- MONTH()The Month Function is a date function that determines the month for a given date in date format. It takes an argument in a date format and displays the result in integer format.read more
- YEAR()The year function in excel is a date function to calculate the year from a given date. This function takes a serial number as an argument and returns a four-digit numeric value representing the year of the given date, formula = year (serial number)read more
Example #7 – Using TEXT() for Inserting Dates in Excel
TEXT() is one of the very important formulas for the presentation of data into a certain desired custom format.
Let us assume the dates as per the above example. We can get the day, month, year, and per the formats mentioned in the third column.
Using the TEXT() as above, we can derive as per the format required.
We can also use the TEXT() in changing the date format as per our requirement. We can avoid going to “Format Cells” and changing the format. It will also reduce the time consumption when changing the format.
Let us see how we can change the format using the TEXT().
TEXT() will also help us in concatenating with a dateTo concatenate a date with other values in Excel, we can use the & operator or the built-in concatenate function. For example, if we use =»ABC»&NOW(), the output will be ABC14/09/2019.read more.
However, when we try to concatenate without using the TEXT() then, it may display the number instead of the date as below:
By using the TEXT(), we can concatenate with an actual date as below:
How to Change the Format of the Inserted Date in Excel?
If we observe from the above example, the date is in the form of MM/DD/YYYY. Suppose we want to change the format, then we can do it as per below:
We should go to the “Control Panel” and select ” Ease of Access.” Then, we can visualize the option of the clock, language, and region.
Click on the above option. It will pop out to other windows where we can get a choice of the region and go on that.
Here, we can select the date format as per our requirement, short date or long date. It will be the default setting of the date once we apply it. If we want to go to the previous format, we can reset it on the window.
Things to Remember
Inserting a valid date in excel should always be stored as a number. We can verify this condition by using ISNUMBER()ISNUMBER function in excel is an information function that checks if the referred cell value is numeric or non-numeric.read more.
Let us take the date in two different formats, as shown above. Inserting a valid date in Excel should always be stored in the number format, so we need to verify the same.
As we check for the number using the ISNUMBER()ISNUMBER function in excel is an information function that checks if the referred cell value is numeric or non-numeric.read more, function, the date which is stored in the form of the number and a valid date will be “TRUE” or else “FALSE.”
In our example above :
- 30/01/2019 – This is TRUE as it is stored in the form of a number, and this date is valid
- 30.01.2019 – This is FALSE, as it is not stored in the form of the number, and it is not valid.
Recommended Articles
This article is a guide to Insert Date in Excel. Here, we discuss how to insert dates in excel along with the top 7 examples using a combination of the DATE(), NOW(), TODAY(), and TEXT() functions. You may also look at these useful functions in Excel: –
- VBA DATEVALUE Function
- EOMONTH Function in Excel
- Date to Text in Excel
- EDATE Function in Excel