Calculate The Number Of Days Between Two Dates In Excel- Extract Next Day Deliveries – Formula Friday


Hello, time for another #formulafriday blog post and today I want to share with you a formula query from a colleague again. This time the query was to extract or highlight next day deliveries out of a list of customer orders. The best way to do this was to calculate the number of days between the two Excel dates we had. Or the date difference. In this way, we could extract those that only had one day between the order date and delivery date that was requested by the customer.

Here is a sample of the data we were working with.

 

 

 

 

 

 

Which Formula To Use To Calculate Days Between Dates?

There are a number of formulas we could use to do this calculation, but let’s keep it simple. Let’s first of all just subtract one date form the other right?. Let’s subtract Delivery Date Requested from Order date.

Notice that we have a date and time of delivery in our data extract, which has an effect on the calculation. Any of the order that came in during the afternoon affects the number of delivery days. That is ok, we could just look at those delivery days that are less than or equal to 1. There is a much straightforward way to get Excel to the hard work for us, and that is to use a built-in formula to calculate the differences in dates. That is the DATEDIF Function.

date difference DATEDIF in excel formula

My favourite formula or function to use for this particular calculation is the DATEDIF function. Strangely Excel does not provide any help or documentation on this since Excel 2000, but it is still available- Only if you type the full formula in yourself.

Formula Syntax Of DATEDIF.

The syntax of the DATEDIF formula is =DATEDIF(Start_Date, End_Date, Interval).

The Start_Date is the starting period that you want Excel to calculate. (Enter this as a number, formula or string).

The End_Date is the last date of the period that you want Excel to calculate. (Enter this as a number, formula or string).

The Interval is how you want Excel to display the difference between the two dates and there are 6 different types of units available, which you can see below.

UNIT Explanation
“Y" Returns the difference as complete years.
“M" Returns the difference as complete months.
“D" Returns the number of days in the period.
“MD" Returns the difference between the days in ‘Start_Date’ and ‘End_Date’. Here the months and years of the dates are ignored.
“YM" Returns the difference between the months in ‘Start_Date’ and ‘End_Date’. Here the days and years of the dates are ignored
“YD" Returns the difference between the days of ‘Start_Date’ and ‘End_Date’. Here the years of the dates are ignored.

So, let’s go back to our order data and use DATEDIF to calculate and highlight our next day deliveries.

DATE DIFFERENCE DATEDIF EXCEL formula

We can see already that the DATEDIF has done its job!. We have correctly returned and identified the next day deliveries. This is now irrespective of the time that the delivery was taken in the ordering system.

Highlight Next Day Deliveries.

To highlight the next day or 1-day delivery we could either use a filter to filter them out, or we could use some conditional formatting to highlight the cell. The choice is yours, and whichever is more applicable to your audience.

If you want to read a little more about Conditional Formatting in Excel then check out my recent blog post below.

Conditional Formatting With A Formula -Format A Cell Based On The Letter It Contains – Formula Friday

 

If you want more Excel and VBA tips then sign up for my Monthly Newsletter where I share 3 Tips on the first Wednesday of the month and receive my free Ebook, 30 Excel Tips.

1

If you want to see all of the blog posts in the Formula Friday series. Click on the link below

How To Excel At Excel – Formula Friday Blog Posts.

More Excel Tips_New1 Excel formula
Learn Excel With Our Excel Online Courses

 

 

 

Barbara

Barbara is an experienced data analyst with over 20 years of experience. Author of the How To Excel At Excel Top 50 Excel tips Ebook, YouTuber and Excel Blogger.

Recent Posts