Excel is date between two dates

Explanation 

In this example, the goal is to check if a given date is between two other dates, labeled «Start» and «End» in the example shown. For convenience, both start (E5) and end (E8) are named ranges. If you prefer not to use named ranges, make sure you use absolute references for E5 and E8.

Excel dates

Excel dates are just large serial numbers and can be used in any numeric calculation or comparison. This means we can simply compare a date to another date with a logical operator like greater than or equal (>=) or less than or equal (<=).

AND function

The main task in this example is to construct the right logical test. The first comparison is against the start date. We want to check if the date in B5 is greater than or equal (>=) to the date in cell E5, which is the named range start:

=B5>=start

The second expression needs to check if the date in B5 is less than or equal (<=) to the end date in cell E5:

=B5<=end

The goal is to check both of these conditions are TRUE at once, and for that, we use the AND function:

=AND(B5>=start,B5<=end) // returns TRUE or FALSE

The AND function will return TRUE when the date in B5 is greater than or equal to start AND less than equal to end. If either test fails, the AND function will return FALSE. We now have the logic we need to use with the IF function.

IF function

We start off by placing the expression above inside the IF function as the logical_test argument:

=IF(AND(B5>=start,B5<=end)

Next, we add a value_if_true argument. In this case, we  want to return an «x» when a date is between two dates, so we add «x» as a text value:

=IF(AND(B5>=start,B5<=end),"x"

If the date in B5 is not between start and end, we don’t want to display anything, so we use an empty string («») for value_if_false. The final formula in C5 is:

=IF(AND(B5>=start,B5<=end),"x","")

As the formula is copied down, the formula returns «x» if the date in column B is between the start and end date. If not, the formula returns an empty string («»), which looks like an empty cell in Excel. The values returned by the IF function can be customized as desired.

Data analysis in Excel often involves working with dates.

A common thing many Excel users need to check when working with dates is whether a date is between two given dates.

A simple use case of this could be when you need to check whether the date of submission of a report was within the given dates or not. Based on this, you can highlight what reports were submitted after the deadline.

In this tutorial, I will show you how to check if the date is between two given dates or not.

Using Nested IF Formula

One of the easiest ways to check whether a date is in between two given dates is by using a simple if formula.

And since we need to check for two conditions, we would need to use two if formulas.

And when you use an IF formula within another IF formula, that is called the nested IF construct.

Below I have a data set where I have the project start date and project end date in column A and column B respectively. And then I have the project submission date in column C.

Dataset to check if date lies between two dates

Now I want to check whether the project submission date was between the project start and project end date or not.

This can easily be done using the below nested IF formula:

=IF(C2>=A2,IF(C2<=B2,"In Range","Out of Range"),"Out of Range")
Formula to check date in between two dates

The above formula would return ‘In Range’ if the date lies in between the two given dates, and it would return ‘Out of Range’ in case the date is either before the project started or after the project end date.

Now let me quickly explain how this formula works.

I first used and if formula to check whether the date is after the project start date or not.

Based on these criteria, I need to specify what should the formula do in case this condition is true, and what should the formula do in case the condition is not true.

But since I have two conditions to check, immediately after I checked the first condition, I use the second IF function to check for the other condition (which is whether the date is before the project end date or not).

Since the IF function takes 3 arguments (the condition, value when the condition is True, and value in the condition is False), for the second IF function, I specify ‘In Range’ as the second argument, as it has satisfied both the conditions, and I specify out of range as the third argument, because it satisfies the first if condition, but it fails the second if condition.

And then finally, I specify ‘Out of Range’ as the second argument for the first IF function (which means that the condition in the first IF function failed, and hence it did not go to the second if function and instead returned the second argument of the first IF function).

Since I had only two conditions to check, I have used two if functions where the second function is nested within the first one. In case you have more than two conditions to check you can further nest these if functions (although it tends to get a bit complicated after a few)

Also read: Avoid Nested IF Function in Excel…VLOOKUP to Rescue

Using IF + AND Formula

While many Excel users are quite comfortable using the IF formula, when you have multiple conditions to check, I prefer using the combination of IF and AND formula instead.

Within the AND formula, you can check for multiple conditions, and can specify what result you should get in case all the conditions are true, and the result you should get in case any of these conditions are FALSE.

Let’s again take the same data set where I have the project started and project end date in column A and column B, and I have the project submission date in column C.

Dataset to check if date lies between two dates

Below is the formula I can use to check whether the submission date lies between the project start date and project end date or not:

=IF(AND(C2>=A2,C2<=B2),"In Range","Out of Range")
IF and AND formula to check in between two dates

The above formula checks for both the conditions and it would return ‘In Range’ in case the submission date is in between the start and the end date, and it would return ‘Out of Range’ in case the submission date is before the project started or after the project end date.

Note that I have still used an IF function in the above formula, however, I didn’t have the need to use two if functions.

Since I had to check for both the conditions, I did that using the AND function instead.

The AND function would return TRUE if both the conditions are true, and it would return FALSE if any or both the conditions are false.

And since I needed a more descriptive output instead of a simple TRUE or FALSE, I have used an IF function where it would give me ‘In Range’ in case the result is TRUE and ‘Out of Range’ in case the result is FALSE.

Check If the Date Occurs on Weekend

A common use case when working with dates in project management is to identify whether a date occurs on a weekend or not.

If you’re checking this manually, you would check whether a date is a Saturday or Sunday.

But when working with dates in Excel, you can use the WEEKDAY function that can easily do this for you.

Below I have a data set where I have some dates in column A, and I want to check whether these dates occur on a weekend or not.

Check if Date is weekend

For the purpose of this tutorial, I would consider Saturday and Sunday as the weekend days.

Below is the formula that will do this for you:

=WEEKDAY(A2,2)>5
WEEKDAY formula to check the date

If the date occurs on a Saturday or Sunday, it will give you a TRUE, else it will give a FALSE.

The above WEEKDAY formula checks the serial number of the date, and returns a number that corresponds to the weekday number for that date. So if it’s a Monday, it would return 1, if it’s a Tuesday it would return 2, and so on.

Since the condition that I’m checking is whether the weekday result is more than 5, it would return TRUE if the date is on a weekend, and it would return FALSE if it’s on a weekday.

If you want the result to be more meaningful, you can use the below if formula, which will return ‘Weekday’ in case the date occurs on a weekday and ‘Weekend’ in case the date occurs on a weekend.

=IF(WEEKDAY(A2,2)>5,"Weekend","Weekday")

Issues When Checking Whether a Date is in Between two dates

So far, I’ve shown you a couple of scenarios where you can check whether a date lies between two given dates.

In all the formulas, the underlying principle is to compare the value of the given date with the start and the end date. If the value of the given date, is in between the start and the end date, then it occurs in between these two dates, else it does not.

However, in some cases, you may see some unexpected results.

In this section, I cover some common pitfalls that you need to be aware of when comparing dates in Excel:

Dates Need to Be in the Right Format

Dates and time values are stored as numbers in the back-end in Excel. So when you compare two dates, you’re essentially comparing two numbers.

You may think that the date looks nothing like a number (for example 01 January 2023), but remember that dates are formatted to show up differently in the cell in Excel, while in the back-end these are still numbers.

For example, a cell may show 01 January 2023, but in the backend, the value of this cell would be 44927 (which indicates the total number of days that have elapsed after 01 Jan 1900).

Now, if your dates are in the right format, all is well.

But there is also a possibility that your date is in a format that Excel does not recognize as a date, which means that instead of a number in the back end, it ends up being considered a text string.

For example, Jan 01, 2023, is not a valid date format in Excel.

So if you have this in a cell in excel, it would be considered a text string, and using this to compare it with other dates can give you incorrect results.

Bottom line – When comparing dates in Excel, make sure that the dates are in the right format

Also read: How to Change Date Format In Excel?

Dates May have a Time Part that’s Hidden

Just like dates, time values are also stored as numbers in the backend in Excel.

While a whole number would indicate a full day, the decimal part would indicate the portion of the day or the time value for that day.

For example, if you have 01-01-2023 18:00:00 in a cell in Excel, in the backend it would be 44927.75, where 44927 means 01-01-2023 and 0.75 means 18:00:00

Now, here’s the problem that you can encounter when checking whether a date lies in between two given dates.

You may clearly see that the date is in between the two given dates, but Excel may give you a different result.

This can happen because most of the time when people work with dates and times, the time portion is hidden so that you only see the date but you do not see the time value.

Below I have a simple example where I have the same date in cells A1 and B1, but when I compare these two cells, it tells me these are not the same.

Date look same but are different

While you can clearly see that these dates are exactly the same, what you do not see is that there is a time value in cell A1 that is hidden so you do not see it. But when excel compares these two cells, it considers these as different (which it rightly should).

While this is not such a common scenario, if this happens, it can sometimes stump even advanced Excel users.

In this tutorial, I showed you a couple of simple formulas that you can use to check whether a date is between two given dates or not.

I’ve also mentioned some of the pitfalls you should be aware of when comparing dates and Excel.

I hope you found this Excel tutorial useful.

Other Excel Tutorials you may also like:

  • Calculate the Number of Months Between Two Dates in Excel
  • How to Calculate the Number of Days Between Two Dates in Excel
  • How to Add or Subtract Days to a Date in Excel
  • How to Stop Excel from Changing Numbers to Dates Automatically
  • How to Add Months to Date in Excel
  • How to Get the Number of Days in a Month in Excel?
  • Get Day Name from Date in Excel

=IF(AND(B9>$C$5,B9<$C$6),»Within»,»Outside»)

=IF(AND(B11>$C$5,B11<$C$6),$C$7,$C$8)

GENERIC FORMULA

=IF(AND(date>start_date,date<end_date),value_if_true,value_if_false)

ARGUMENTS
date: A date that you want to test if it’s between two dates.
start_date: A start date that you want to test the date against.
end_date: An end date that you want to test the date against.
value_if_true: Value to be returned if the date is between the start and end date.
value_if_false: Value to be returned if the date does not fall between the start and end date.

GENERIC FORMULA

=IF(AND(date>start_date,date<end_date),value_if_true,value_if_false)

ARGUMENTS
date: A date that you want to test if it’s between two dates.
start_date: A start date that you want to test the date against.
end_date: An end date that you want to test the date against.
value_if_true: Value to be returned if the date is between the start and end date.
value_if_false: Value to be returned if the date does not fall between the start and end date.

EXPLANATION

This tutorial shows how to test if a specific date falls between two dates and return a value if the test is True or False.

Click on either the Hard Coded or Cell Reference button to view the formula that has the return values directly entered into the formula or referenced to specific cells.

In this example the formula initially identifies if a date is greater than the start date and less than the end date through the use of an AND function with the greater than (>) and less than (<) signs. This is enclosed in the IF function to test if this is True and if so the formula will return a text value of «Within», otherwise if the test is False the formula will return a text value of «Outside». In this example we have only used one pair of start and end dates and applied them to all of the three dates we are testing. You can have different start and end dates for each of the dates that you are testing with different True and False return values.

Use the DATEDIF function when you want to calculate the difference between two dates. First put a start date in a cell, and an end date in another. Then type a formula like one of the following.

Warning: If the Start_date is greater than the End_date, the result will be #NUM!.

Difference in days

=DATEDIF(D9,E9,"d") with result of 856

In this example, the start date is in cell D9, and the end date is in E9. The formula is in F9. The “d” returns the number of full days between the two dates.

Difference in weeks

=(DATEDIF(D13,E13,"d")/7) and result: 122.29

In this example, the start date is in cell D13, and the end date is in E13. The “d” returns the number of days. But notice the /7 at the end. That divides the number of days by 7, since there are 7 days in a week. Note that this result also needs to be formatted as a number. Press CTRL + 1. Then click Number > Decimal places: 2.

Difference in months

=DATEDIF(D5,E5,"m") and result: 28

In this example, the start date is in cell D5, and the end date is in E5. In the formula, the “m” returns the number of full months between the two days.

Difference in years

=DATEDIF(D2,E2,"y") and result: 2

In this example, the start date is in cell D2, and the end date is in E2. The “y” returns the number of full years between the two days.

Calculate age in accumulated years, months, and days

You can also calculate age or someone’s time of service. The result can be something like “2 years, 4 months, 5 days.”

1. Use DATEDIF to find the total years.

=DATEDIF(D17,E17,"y") and result: 2

In this example, the start date is in cell D17, and the end date is in E17. In the formula, the “y” returns the number of full years between the two days.

2. Use DATEDIF again with “ym” to find months.

=DATEDIF(D17,E17,"ym") and result: 4

In another cell, use the DATEDIF formula with the “ym” parameter. The “ym” returns the number of remaining months past the last full year.

3. Use a different formula to find days.

=DATEDIF(D17,E17,"md") and result: 5

Now we need to find the number of remaining days. We’ll do this by writing a different kind of formula, shown above. This formula subtracts the first day of the ending month (5/1/2016) from the original end date in cell E17 (5/6/2016). Here’s how it does this: First the DATE function creates the date, 5/1/2016. It creates it using the year in cell E17, and the month in cell E17. Then the 1 represents the first day of that month. The result for the DATE function is 5/1/2016. Then, we subtract that from the original end date in cell E17, which is 5/6/2016. 5/6/2016 minus 5/1/2016 is 5 days.

Warning: We don’t recommend using the DATEDIF «md» argument because it may calculate inaccurate results.

4. Optional: Combine three formulas in one.

=DATEDIF(D17,E17,"y")&" years, "&DATEDIF(D17,E17,"ym")&" months, "&DATEDIF(D17,E17,"md")&" days" and result: 2 years, 4 months, 5 days

You can put all three calculations in one cell like this example. Use ampersands, quotes, and text. It’s a longer formula to type, but at least it’s all in one. Tip: Press ALT+ENTER to put line breaks in your formula. This makes it easier to read. Also, press CTRL+SHIFT+U if you can’t see the whole formula.

Download our examples

Other date and time calculations

As you saw above, the DATEDIF function calculates the difference between a start date and an end date. However, instead of typing specific dates, you can also use the TODAY() function inside the formula. When you use the TODAY() function, Excel uses your computer’s current date for the date. Keep in mind this will change when the file is opened again on a future day.

=DATEDIF(TODAY(),D28,"y") and result: 984

Please note that at the time of this writing, the day was October 6, 2016.

Use the NETWORKDAYS.INTL function when you want to calculate the number of workdays between two dates. You can also have it exclude weekends and holidays too.

Before you begin: Decide if you want to exclude holiday dates. If you do, type a list of holiday dates in a separate area or sheet. Put each holiday date in its own cell. Then select those cells, select Formulas > Define Name. Name the range MyHolidays, and click OK. Then create the formula using the steps below.

1. Type a start date and an end date.

Start date in cell D53 is 1/1/2016, end date is in cell E53 is 12/31/2016

In this example, the start date is in cell D53 and the end date is in cell E53.

2. In another cell, type a formula like this:

=NETWORKDAYS.INTL(D53,E53,1) and result: 261

Type a formula like the above example. The 1 in the formula establishes Saturdays and Sundays as weekend days, and excludes them from the total.

Note: Excel 2007 doesn’t have the NETWORKDAYS.INTL function. However, it does have NETWORKDAYS. The above example would be like this in Excel 2007: =NETWORKDAYS(D53,E53). You don’t specify the 1 because NETWORKDAYS assumes the weekend is on Saturday and Sunday.

3. If necessary, change the 1.

Intellisense list showing 2 - Sunday, Monday; 3 - Monday, Tuesday, and so on

If Saturday and Sunday are not your weekend days, then change the 1 to another number from the IntelliSense list. For example, 2 establishes Sundays and Mondays as weekend days.

If you are using Excel 2007, skip this step. Excel 2007’s NETWORKDAYS function always assumes the weekend is on Saturday and Sunday.

4. Type the holiday range name.

=NETWORKDAYS.INTL(D53,E53,1,MyHolidays) and result: 252

If you created a holiday range name in the “Before you begin” section above, then type it at the end like this. If you don’t have holidays, you can leave the comma and MyHolidays out. If you are using Excel 2007, the above example would be this instead: =NETWORKDAYS(D53,E53,MyHolidays).

Tip: If you don’t want to reference a holiday range name, you can also type a range instead, like D35:E:39. Or, you could type each holiday inside the formula. For example if your holidays were on January 1 and 2 of 2016, you’d type them like this: =NETWORKDAYS.INTL(D53,E53,1,{«1/1/2016″,»1/2/2016»}). In Excel 2007, it would look like this: =NETWORKDAYS(D53,E53,{«1/1/2016″,»1/2/2016»})

You can calculate elapsed time by subtracting one time from another. First put a start time in a cell, and an end time in another. Make sure to type a full time, including the hour, minutes, and a space before the AM or PM. Here’s how:

1. Type a start time and end time.

Start date/time of 7:15 AM, End date/time of 4:30 PM

In this example, the start time is in cell D80 and the end time is in E80. Make sure to type the hour, minute, and a space before the AM or PM.

2. Set the h:mm AM/PM format.

Format cells dialog box, Custom command, h:mm AM/PM type

Select both dates and press CTRL + 1 (or Image of the MAC Command button icon + 1 on the Mac). Make sure to select Custom > h:mm AM/PM, if it isn’t already set.

3. Subtract the two times.

=E80-D80 and result: 9:15 AM

In another cell, subtract the start time cell from the end time cell.

4. Set the h:mm format.

Format Cells dialog, Custom command, h:mm type

Press CTRL + 1 (or Image of the MAC Command button icon + 1 on the Mac). Choose Custom > h:mm so that the result excludes AM and PM.

To calculate the time between two dates and times, you can simply subtract one from the other. However, you must apply formatting to each cell to ensure that Excel returns the result you want.

1. Type two full dates and times.

Start date of 1/1/16 1:00 PM; End date of 1/2/16 2:00 PM

In one cell, type a full start date/time. And in another cell, type a full end date/time. Each cell should have a month, day, year, hour, minute, and a space before the AM or PM.

2. Set the 3/14/12 1:30 PM format.

Format Cells dialog, Date command, 3/14/12 1:30 PM type

Select both cells, and then press CTRL + 1 (or Image of the MAC Command button icon + 1 on the Mac). Then select Date > 3/14/12 1:30 PM. This isn’t the date you’ll set, it’s just a sample of how the format will look. Note that in versions prior to Excel 2016, this format might have a different sample date like 3/14/01 1:30 PM.

3. Subtract the two.

=E84-D84 and result of 1.041666667

In another cell, subtract the start date/time from the end date/time. The result will probably look like a number and decimal. You’ll fix that in the next step.

4. Set the [h]:mm format.

Format Cells dialog, Custom command, [h]:mm type

Press CTRL + 1 (or Image of the MAC Command button icon + 1 on the Mac). Select Custom. In the Type box, type [h]:mm.

Related Topics

DATEDIF function

NETWORKDAYS.INTL function

NETWORKDAYS

More date and time functions

Calculate the difference between two times

Written by Allen Wyatt (last updated December 21, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


Johna needs to determine if a particular date is between two other dates. For instance, she may need to determine if November 8, 2018, is between August 1, 2018, and July 31, 2019. She is trying to figure out the formula that will make this determination.

There are actually a wide range of formulas you could use, ranging from the short to the very long. In this tip, though, I’ll focus on the shorter formulaic approaches. Before doing so, it is good to remember that dates (and times) are stored internally by Excel as numbers. The portion of the date before the decimal point (the integer portion of the number) is the serial number for the date, and the portion to the right of the decimal place is the time.

Since dates and times are stored as numbers, it becomes a relatively easy task to simply compare the numbers to determine which is higher or lower and if something is between the high and low. For instance, let’s assume that you have your starting date (August 1, 2018) in cell A1 and your ending date (July 31, 2019) in cell A2. You could place the date to check into cell D1 and use the following formula:

=IF(AND(D1>=A1,D1<=A2),"Yes","No")

The formula checks to see if the date in D1 is both greater than or equal to A1 and less than or equal to A2. Only if those two conditions are met is «Yes» returned, otherwise «No» is returned. (See Figure 1.)

Figure 1. Comparing numbers to determine which is higher or lower and between the high and low.

If you think that the dates include times, then you may want to adjust for that by stripping off the portion of the serial number that represents the time:

=IF(AND(TRUNC(D1,0)>=TRUNC(A1,0),TRUNC(D1,0)<=TRUNC(A2,0)),"Yes","No")

If you are actually comparing text strings and not recognized Excel dates, then you’ll need to use the DATEVALUE function to convert the strings into dates:

=IF(AND(DATEVALUE(D1)>=DATEVALUE(A1),DATEVALUE(D1)<=DATEVALUE(A2)),"Yes","No")

The result of using the DATEVALUE function would be similar to the following figure: (See Figure 2.)

Figure 2. Comparing text strings using the DATEVALUE function to convert strings into dates.

Each of the formulas, so far, has been the same basic formula; the only thing different between them is the adding of additional functions to compensate for the characteristics of how the dates are stored in the cells. For an entirely different way to determine if a date is between two other dates, you could use the following formulaic approach:

=IF(D1=MEDIAN(D1,A1,A2),"Yes","No")

Since the MEDIAN function is calculated using three numbers, it always returns the number that is between the lower and the higher number. This means that if D1 is really between the other two, it will always be returned; if D1 is not between the other two, then one of the others will be returned.

Interestingly, if you reorganized your data a bit so that the three values were adjacent to each other (for instance, by moving the comparison date from D1 to A3), then you could replace the three separate cell references with a range of the three cells, making the formula even shorter:

=IF(A3=MEDIAN(A1:A3),"Yes","No")

The advantage to using the MEDIAN approach to the AND approach is that you don’t need to worry which of the range values (A1 or A2) is the start or the end date for the comparison—the MEDIAN function sorts that all out. (See Figure 3.)

Figure 3. Comparing values using the MEDIAN funtion.

ExcelTips is your source for cost-effective Microsoft Excel training.
This tip (12742) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

Author Bio

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. Learn more about Allen…

MORE FROM ALLEN

Returning the Smallest Non-Zero Value

In a series of values, you may need to know the smallest value that isn’t a zero. There is no built-in function to do …

Discover More

Updating the Spelling Exclusion List Automatically

Want to add words easily to the spelling exclusion list? Here’s a macro that can make the task completely painless.

Discover More

Generating Random Door Access Codes

People often use Excel to maintain lists of information that they need to track. This tip shows several ways you can …

Discover More

Since you imply you might need to return multiple names, I would suggest the Advanced Filter. Look at HELP for how to set it up. But assume that you enter the date into cell G1. Your Criteria Range might look like (showing the formulas and not the results that show in those cells)

leavefrom       leaveupto
 ="<="&D1        =">="&D1

Post back if you need more help

Here’s a picture of using the Advanced Filter. Note the options in the Dialog Box to «Copy to another location», and the address to «copy to»

enter image description here

One can develop macro code to automate the updating of the advanced filter, if this is what you want to do. First make sure the filter does what you require.

Here is Macro Code to run after the date has been changed by your user. See if it works for you. You will likely have to modify it for your specific situation.

If it works, you can set up a button to run it. If that also works, you can develop code to trigger it by an appropriate Event, to completely automate things.

Option Explicit
Sub LeaveList()
    Dim rDateCheck As Range
    Dim rSrc As Range
    Dim rCriteria As Range
    Dim rRes As Range

Set rDateCheck = Range("G1") 'or wherever you have the date
    If Not IsDate(rDateCheck) Then
        MsgBox "You MUST enter a Date!"
    Exit Sub
    End If
Set rRes = Range("I1") 'or wherever you want the results
    rRes.Resize(columnsize:=3).EntireColumn.Clear

With Cells
    Set rSrc = .Find(what:="Name", after:=Cells(.Rows.Count, .Columns.Count), _
                LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByColumns, _
                searchdirection:=xlNext, MatchCase:=False)
    'assume LeaveTable separated from rest of sheet by at least one empty
    '   column and row
    Set rSrc = rSrc.CurrentRegion
End With

'Move Leave Table to leave room for Criteria Range
With rSrc
    If .Row < 5 Then _
        Range(.Rows(1), .Rows(5 - .Row)).Insert shift:=xlDown
End With

'Put Criteria Range above Table
Set rCriteria = Cells(1, rSrc.Column).Resize(2, 2)
    rCriteria.Interior.Color = vbYellow
    rCriteria(1, 1) = rSrc(1, 2)
    rCriteria(1, 2) = rSrc(1, 3)
    rCriteria(2, 1).Formula = "=""<="" & " & rDateCheck.Address
    rCriteria(2, 2).Formula = "="">="" & " & rDateCheck.Address

   rSrc.AdvancedFilter xlFilterCopy, rCriteria, rRes
End Sub

This post will guide you how to calculate value between two dates if the dates falls those two dates in Excel. How do return a value if the dates fall between two given dates in excel. How to use a formula to determine whether a date falls between two dates in Excel. How to check if a date falls between a range of two dates in Excel.

Table of Contents

  • Determine Whether a Date Falls between Two Dates
    • Related Functions

Determine Whether a Date Falls between Two Dates


Assuming that you have a list of data that contain dates in one column or range, and you want to check those dates if fall between two given dates in range C1:D1. How to achieve it. You can create a formula based on the IF function, and the AND function. Like this:

=IF(AND(A1>$C$1,A1<$D$1),TRUE,FALSE)

Type this formula into Cell B1, and press Enter key in your keyboard, and then drag the AutoFill Handle from Cell B1 to B5.

return value if date fall two dates1

If the data falls between the given two dates, and this formula return TRUE, otherwise, return FALSE.


  • Excel IF function
    The Excel IF function perform a logical test to return one value if the condition is TRUE and return another value if the condition is FALSE. The IF function is a build-in function in Microsoft Excel and it is categorized as a Logical Function.The syntax of the IF function is as below:= IF (condition, [true_value], [false_value])….
  • Excel AND function
    The Excel AND function returns TRUE if all of arguments are TRUE, and it returns FALSE if any of arguments are FALSE.The syntax of the AND function is as below:= AND (condition1,[condition2],…) …




  • Excel Howtos

Between Formula in Excel [Quick Tips]


  • Last updated on June 24, 2010

Chandoo

Chandoo

In today’s quick tip, lets find how to check for between conditions in Excel using formulas, like this:

Between Formula - Testing for between condition in Excel

Between Formula in Excel for Numbers:

Lets say you have 3 values in A1, A2 and A3. And you want to find out if A1 falls between A2 and A3.

Now, the simplest formula for such a thing would be test whether the conditions A1>=A2, A1<=A3 are both true. Hence, it would look like,
=if(AND(A1>=A2,A1<=A3),"Yes", "No")

However, there are 2 problems with a formula like above:

1. It assumes that A2 is smaller than A3.
2. It is just too big.

Shouldn’t there be a shorter and simpler formula?!?

Well, there is. Last week when chatting with Daniel Ferry, he mentioned a darned clever use of MEDIAN formula to test this. It goes like,

=if(A1=MEDIAN(A1:A3),"Yes","No")

Now, not only does the above formula look elegant and simple, it also works whether A2 is smaller or larger than A3.

Between Formula in Excel for Dates:

Well, dates are just numbers in Excel. So you can safely use the technique above to test if a given date in A1 falls between the two dates in A2 and A3, like this:
=if(A1=MEDIAN(A1:A3),"Yes","No")

Between Formula for Text Values:

Lets say you want to find-out if the text in A1 is between text in A2 and A3 when arranged alphabetically, a la in dictionary. You can do so in Excel using,

wait for it…

that is right, <= and >= operators, like this:
=if(AND(A1>=A2,A1<=A3),"Yes", "No")

Between Formulas in Excel – Summary and Examples:

Here is a list of examples and the corresponding Excel Formulas to test the between condition.

Between Formula in Excel - Examples

Do you check for Between Conditions in Excel?

Checking if a value falls between 2 other values is fairly common when you are working with data. I would love to know how you test for such conditions in excel? What kind of formulas do you use?

Share using comments.

Recommended Excel Formula Tutorials:

  • Check for Either Or conditions in Excel
  • Find out if 2 ranges of dates overlap using formulas
  • Get my Excel Formulas e-Book, learn 75 most used formulas overnight


Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.




  • 208 Comments




  • Ask a question or say something…




  • Tagged under

    and(), between formula, Excel 101, if() excel formula, Learn Excel, logical operators in excel, median() formula, Microsoft Excel Formulas, quick tip, spreadsheets, using excel




  • Category:

    Excel Howtos

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my story • FREE Excel tips book

Advanced Excel & Dashboards training - Excel School is here

Excel School made me great at work.

5/5

Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It’s all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

A smart technique to simplify lengthy nested IF formulas in Excel

  • Excel for beginners
  • Advanced Excel Skills
  • Excel Dashboards
  • Complete guide to Pivot Tables
  • Top 10 Excel Formulas
  • Excel Shortcuts
  • #Awesome Budget vs. Actual Chart
  • 40+ VBA Examples

Related Tips

208 Responses to “Between Formula in Excel [Quick Tips]”

  1. Clever use of MEDIAN, but it returns «Yes» if you use the upper or lower number. Whether you want to consider 20 as being «between» 10 and 20 is up to you.

    Also, the examples made it harder to understand. In the first formula you use A1:A3 for the range, but the first picture looks like the formula is filled across rows, not columns.

  2. @JP —
    MEDIAN can be used regardless of your definition of «between.» To include the boundary points, I would write it like this:
    .
    =A1=MEDIAN(A1:A3)
    .
    To exclude them:
    .
    =A1=MEDIAN(A1,A2+1,A3-1)
    .
    Regards,
    Daniel Ferry
    excelhero.com

    • Lucky says:

      Hi I want to find out the difference in two numbers. But if the second number is minus it should not turn into plus in the results. Could you tell me the formula for it. Example (21.32)(-6.37) MY expectation to get the difference in between these two numbers. The answer should be 14.95. I do not hope the answer as 27.69. The actual mathematical answer that turn the second minus into plus and adds together. But excel always give me the second answer but please tell me the formula for the first answer. The deference between the numbers. Thanks

      • @Lucky
        =21.32-abs(-6.37)
        or
        =Abs(A1)-Abs(A2)

  3. Rob says:

    Daniel —

    your formula to exclude the boundary points would only work if you’re dealing strictly with integers. For example, if you test if 19.5 is between 10 and 20 using A1=MEDIAN(A1,A2+1,A3+1), it would fail.

    Rob

  4. Rob says:

    I should clarify…I think it’s a very creative use of MEDIAN and if you’re testing numbers and want to include the end points, it’s a simpler method, but you need to use the other style using just instead of = to properly not include end points.
    Rob

  5. Rob says:

    darn…should have known my greater than and less than characters would be removed.

    Meant to say you need to use the and() style test using just less than and greater than characters without the equal signs.
    Rob

  6. cALi says:

    I tried it using spanish MEDIANA(…) function, but it didn’t work. This is what I did, not such stylish, but it works fine: =IF(AND(A1=MIN(B1:C1)),»YES»,»NO»).

    cALi

  7. @Rob —

    You bring up a good point that I should have clarified. When using the method I shared above to exclude the boundary points, the user is responsible for the precision. I have used this technique for years with operations scheduling and task management, often with a precision of days. However, I have used it with finer precision, hours, minutes, seconds. Again this is totally up to the user; he can use whatever value he wants instead of the integers of one:
    .
    =A1=MEDIAN(A1,A2+1/24,A3-1/24)
    .
    =A1=MEDIAN(A1,A2+1/24/60,A3-1/24/60)
    .
    =A1=MEDIAN(A1,A2+1/24/60/60,A3-1/24/60/60)
    .
    …of course those constants could/should be replaced by defined names.
    .
    Taking this to the extreme, one could easily define a constant that equals the smallest positive value that Excel can represent:
    .
    spv: =2.229E-308
    .
    We can then write the formula as:
    .
    =A1=MEDIAN(A1,A2+spv,A3-spv)
    .
    …which will work for any possible decimal value between the boundary points. It’s a robust and elegant solution, imo.

    Regards,
    Daniel Ferry
    excelhero.com

  8. cALi says:

    Sorry, when copying and pasting, I should made some mistake, this is real one:
    =IF(AND(A1=MIN(B1:C1)),»YES»,»NO»)

    A1: tested in Between Value
    B1 and C1: limits

  9. cALi says:

    I suppose HTML is in conflict with the code. Same code, different order of the arguments in the AND function:
    =IF(AND(A1>=MIN(B1:C1),A1<=MAX(B1:C1)),»YES»,»NO»)

  10. David says:

    The formula =IF(A1=MEDIAN(B1:C1),»Yes»,»No») does not work when I tested it. It returns «No» for any value in A1, regardless if it falls between B1 and C1 or not.

  11. @cALi —
    I have no experience with the Spanish version of Excel, but I would be very surprised to learn that the worksheet functions differed in their outputs! Can you provide the exact formula (in Spanish) that did not work for you?
    .
    On a different note, here is an equivalent formula to yours, that does not use the AND() function, nor the IF() function:
    .
    =A1=MIN(MAX(A1:B1),MAX(B1:C1))
    .
    BTW, your formula (and hence my variation of it) has the characteristic where «between» includes the lower boundary point, but not the higher one. This can be altered in a similar fashion as my above example.
    .
    Regards,
    Daniel Ferry
    excelhero.com

  12. @Daniel —
    We can also do both.

    For example, I created a data validation in cell H2 consisting of «True,False» values. (That is, True and False without quotes).

    This formula would then allow you to toggle the output as exclusive or inclusive of the start and end numbers by changing the value in H2 (True means exclude, False means include):

    =B3=MEDIAN(B3,C3+N(H2),D3-N(H2))

  13. @JP —
    That’s it!
    Imagine the nested IF monster that you just avoided! Good job.
    That is why I am always going on about better solutions to haplessly using IF(), when one understands the problem.
    .
    Regards,
    Daniel Ferry
    excelhero.com

  14. cALi says:

    @Daniele

    Thanks for your time, I made some mistake since testing both alternatives I received the same results:
    =An=MIN(MAX(An:Bn),MAX(Bn:Cn))
    =An=MEDIAN(An:Cn)

    Indeed, your solution is not just elegant but also practical, I could name it «minimalist».

    Best regards,
    cALi

  15. @David.. you have to include A1 as well to get it right. Like this,

    =IF(A1=MEDIAN(A1,B1,C1),”Yes”,”No”)

  16. sam says:

    @ JP Instead of True/False use 1,0, we can then drop the N()

    =B3=MEDIAN(B3,C3+H2,D3-H2)

  17. Tim Buckingham says:

    Turned into UDF for kicks

    Function ISBETWEEN(Rng, num1, num2) As Boolean
    ‘ Checks if value between num1 and num2
    Dim Low As Double, Hi As Double

    ISBETWEEN = False

    Low = Application.Min(num1, num2)
    Hi = Application.Max(num1, num2)

    If Rng Is Nothing Then Exit Function
    If Rng = Application.WorksheetFunction.Median(Rng, Low, Hi) Then ISBETWEEN = True

    End Function

    I like how easy it is to read when wanting to count the values that fall between using

    =COUNTIF(Rng,ISBETWEEN(Rng,Num1,Num2))

  18. Gerald Higgins says:

    I think the use of the MEDIAN function is very clever.

    Nitpicking now.
    If I understand correctly, Daniel’s suggestion for an amendment to exclude the =boundaries case as in
    =A1=MEDIAN(A1,A2+1/24,A3-1/24)
    assumes that all the numbers involved are positive.
    If one or both of the boundary numbers are negative, I think this formula will produce wrong results for values of A1 just outside the true boundary range.

    Also, this formula
    =A1=MIN(MAX(A1:B1),MAX(B1:C1))
    works as long as the C1 value is higher than the B1 value, but not the other way round, which was described asa fault in the OP.
    This formula solves that particular problem (it’s essentially the same as cALi’s)
    =AND(A1MIN(B1:C1))
    Replace < with <= as required.

  19. Gerald Higgins says:

    Sorry, lost symbols in my last post.
    I’ll try again.
    The last formula should be
    =AND(A1 (less than symbol) MAX(B1:C1),A1 (greater than symbol) MIN(B1:C1))

  20. elad says:

    CooL :)))) very elegant solution !

  21. Guest says:

    Great use of the function — I will be using this.
    As always though, formulaic results are only as good as the data on which they’re based (it’s spelled «coyote» instead of «cayote,» so your last text example should actually read yes. 🙂
    Not to nitpick….but to nitpick… 🙂

  22. @sam —

    «Instead of True/False use 1,0, we can then drop the N()»

    That’s true, but who’s going to understand that? If your users can, they’re much smarter than mine.

  23. […] the problem is similar to between formula trick we discussed a few days back, yet very […]

  24. […] Between Formula in Excel, Chandoo presents some formulas for determining if a given value is in between two known […]

  25. Daniel’s spv approach does not work because the spv addon never makes it into the mantissa of the floating point numbers.

    Regards,
    Bernd

  26. @Bernd —

    With all due respect, you should double check that.

  27. Daniel,
    Excel 2010 (version 14.0.4760.1000 32 bit), spv set to 2.229E-308, A1 = 1, A2 = 1, A3 = 2, result A1=MEDIAN(A1,A2+spv,A3-spv) = True (should be False).
    Again, if I am not mistaken, the very small value does not make it into the mantissa of the MEDIAN parameters which will then lead to MEDIAN(1,1,2) = True.
    Regards,
    Bernd

  28. Daniel,
    I do like the spv idea. My suggestion to fix the mantissa issue would be something like this:
    =A1=MEDIAN(A1,A2+POWER(10,INT(LOG10(A2))-14),A3-POWER(10,INT(LOG10(A3))-14))
    But this is sort of a monster formula again. Maybe two functions InfInc and InfDec (for infinitesimal increase / decrease) should be introduced which return the smallest float greater than the input (resp. the greatest float which is smaller).
    Regards,
    Bernd

  29. @Bernd —
    .
    Touche.
    .
    While the formula logic is correct, Excel does not handle the very, very small number correctly in this instance. Good bug catch.
    .
    As I mentioned above, I have used the MEDIAN method countless times, but usually with dates, but also to the precision of hours, minutes, and seconds. I’ve never actually tried to use it with such fine precision before. I should have tested it before commenting, as Murphy’s Law always prevails.
    .
    After testing I discovered that 1E-14 is the finest precision where my idea does work. To be sure, this will work in virtually every situation, as this is a very small number:
    .
    0.00000000000001
    .
    In fact, this is exactly what your POWER/LOG formula results in. So there is no need to use the monster formula.
    .
    Instead of defining spv as the smallest possible value (in Excel) we can simply enter it’s definition as:
    .
    =1e-14
    .
    and now spv can stand for the smallest possible value (handled correctly).

  30. Daniel,
    I am sorry, but — no, you cannot take an absolute 1e-14. Please note that my POWER/LOG formula flexibly adjust itself to the number in question:
    For 1 it’s 1e-14, for 10 it’s 1e-13, for 100 it’s 1e-12, …
    It will exactly impact on the lowest digit of the mantissa. Please note that it can be different for the two MEDIAN border parameters. Please see my example at
    http://www.sulprobil.com/html/test_if_between_2_values.html
    Regards,
    Bernd

  31. Rick Rothstein (MVP — Excel) says:

    There is always this purely mathematical method for determining if a value (A1) is between two limits (A2 and A3) excluding the end points…

    =If(ABS(A1-((A2+A3)/2)).LT.ABS(A3-A2)/2,»Yes»,»No»)

    To make it include the end points, change the less than to less than or equal….

    =If(ABS(A1-((A2+A3)/2)).LE.ABS(A3-A2)/2,»Yes»,»No»)

    Note that I used (with the surrounding dots) .LT. for the «less than» symbol and .LE. for the «less than or equal» symbol. Now, the only thing I am unsure of is how to adjust this for the spv that was brought up in the latter comments… anyone want to take a stab at it?

  32. Rick,
    Your ABS approach makes perfect sense for small numbers (ASCII code) or floats that are in the same ball park.
    But test the values 0, 1, 2, 3, …, 9 on the border values 1e16 and 5 with .LT. and with .LE.
    The ABS approach gets it horribly wrong here because the lower border value 5 gets off the mantissa when added or subtracted to or from 1e16.
    Regards,
    Bernd

  33. Rick Rothstein (MVP — Excel) says:

    @Bernd,

    While it is possible, of course, I would not normally expect a test for inclusion within a range to have such wildly divergent end points for the range.

  34. Rick,
    Why risk anything if you can only lose? If I deal with floating point numbers of unknown size and if I need to know whether a number is between two others I would use neither the MEDIAN approach nor the ABS approach.
    I think it’s far more important to know the basics about floating point numbers than to know this MEDIAN «trick» or the ABS comparison:
    http://docs.sun.com/source/806-3568/ncg_goldberg.html
    Regards,
    Bernd

  35. Debbie says:

    Thanks for posting…! Worked perfectly for what I needed!!!

  36. sanjeev khendi says:

    i want to if function/ if total sales 200000 ,then com rate =5% give me information how to solve it with example

  37. Hui… says:

    @Sanjev
    Assuming you are entering this in the cell representing Com Rate
    =if(sum(sales range)>=200000,5%,10%)
    10% is the value for Com Rate if sales

  38. cALi says:

    @Sanjev
    Using Daniel Ferry approach about IF function, which I have embraced as mine:

    C D E
    Lower Limit Upper Limit Commission Rate
    ?

  39. cALi says:

    @Sanjev
    Using Daniel Ferry approach about IF function, which I have embraced as mine:

    C D E
    Lower Limit Upper Limit Commission Rate
    4 Range1 — 100,000.00 0%
    5 Range2 100,000.00 200,000.00 2%
    6 Range3 200,000.00 1,000,000.00 5%
    7 Range4 1,000,000.00 1E+100 6%
    8
    9 Actual Sales 180,000.00
    Comm. Rate 2% =SUMPRODUCT((C4:C7

  40. cALi says:

    @ Chandoo, really sorry for the mess, the text editor is definitely not my friend… this will be my last chance, I hope it works…

    @ Sanjeev,
    Using Daniel Ferry IF function approach, and using some dummy data:

    A B C D
    Lower Limit Upper Limit Commission Rate
    3 Range1 — 100,000.00 0%
    4 Range2 100,000.00 200,000.00 2%
    5 Range3 200,000.00 1,000,000.00 5%
    6 Range4 1,000,000.00 1E+100 6%
    7 Actual Sales 180,000.00
    8 Comm. Rate 2% =SUMPRODUCT((B3:B6?$B$7)*($B$7?C3:C6)*D3:D6)

    Please replace ‘?’ with ‘less than or equal to’ and ‘?’ with ‘less than’ proper operators.
    By the way, C6 is a dummy value, is ‘upper infinite’ to make this approach work.

    Regards,
    cALi

  41. […] Between Formula in Excel […]

  42. KM says:

    Sales Achievement
    15,001 — 20,000 EL
    20,001 — 50,000 E
    50,001 — 100,000 D
    100,001 — 160,000 C
    160,001 — 240,000 B
    240,001 & above A

    If the sales achievement fall in between 50,001-100,000 is under Class D, can you help if i have many column of acheivement data which fall under different class. How can i set the formula in one time?

  43. @KM
    Are your Ranges in 1 Column or 3
    ie: is 15,001 – 20,000 in 1 cell or 3 cells

  44. I want drop my serial no continuous automatically from the input value
    e.g I have list of TV I given code for that
    TV001
    TV002
    TV003
    THEN I START ADDING BIKE
    BIKE001
    BIKE002
    AGAIN I WANT ADD TV FROM PREVIOUS NUMBER CONTINUATION
    LIKE
    TV004
    TV005
    again i want add bike003 cotinuation from last number
    IS THERE ANY FORMULAS FOR THAT?
    PLEASE SEND THIS TO MY EMAIL ADDRESS sent to mani.n@govasool.com

  45. Antony says:

    i have a problem: i have 2 rows, A1 and A2 are containing ID which are same. B1 has to be compared with B2 and B3, and if B1 falls between them then it should tell «YES» else «NO». How will I do this????

  46. @Antony
    Assuming B2 <= B3 then use:
    =IF(AND(B1>=B2,B1<=B3),»Yes»,»No»)

  47. @ Hui,
    I have precisely the same situation as @KM has (in comment 40). I have the values in three colums («range begin», «range end», «category»). I need to find out in which range a given value lies and fetch the corresponding category. Help pls.

  48. Sid says:

    How do I use to it see if a time value is between 2 values
    Example if 09:18:24 is between 09:18:00 and 09:19:00

  49. Sid,
    .
    Exactly the same way!
    .
    Assume your times are in these cells:
    .
    A1 = 09:18:24
    A2 = 09:18:00
    A3 = 09:19:00
    .
    The formula from any other cell will determine if 09:18:24 is between the other two values:
    .
    =A1=MEDIAN(A1:A3)

    • Michael says:

      How can I make it tell me if the current time and date is between two other times and dates.

      I am working with the following:

      Lets say that the time right now is Thursday at 4 PM. How would this work out?
      Thursday: 11:00 AM — 2:00 AM (Friday)

      Then imagine that the current time is  Friday at 1 AM.

      Thanks!!!! 

      • @Michael
        =MEDIAN(DATE(2012,12,10)+TIME(11,0,0), DATE(2012,12,11)+TIME(16,0,0), DATE(2012,12,12)+TIME(18,0,0)) = DATE(2012,12,11)+TIME(16,0,0)
        Adjust Dates/Times to suit

        or

        =MEDIAN(A1, A2, A3)=A1
        where A1 is the Date/Time now
        A2 & A3 are the other dates/times

        • Michael says:

          Thanks for your help.

          I’m a little unsure how to interpret your answer….

          Also, where would I insert the following?

          «DATE(2012,12,day(today()))+TIME(Hour(now()),minute(now()),second(now()))»

          I think I would substitute this in at the end of your answer’s equation for the «= DATE(2012,12,11)+TIME(16,0,0)» part, so that my equation will always work… right? thanks again!!!

          • The Format is:

             
            =Median(Start Date, End Date, Now)=Now
            it doesn’t matter what order the components go
            so:
            =Median(Now, End Date, Start Date)=Now
            is Just as valid
            If you use the Now() function that already includes the date & time
            So you can use
            =Median(Start Date+Time, End Date+Time, Now())=Now()
            =MEDIAN(DATE(2012,12,13)+TIME(11,0,0),DATE(2012,12,14)+TIME(2,0,0), Now())=Now()
            or if you want to use Today
            eg: 11am today until 2am tomorrow
            =MEDIAN(Int(Now())+Time(11,0,0),Int(Now()+1)+TIME(2,0,0), Now())=Now()

  50. msog says:

    Daniel,

    I’m quite confused by the results I’m receiving when trying this formula. I’m using it to try to validate if a date is between two other dates using the «short date» format. I receive «NO» all statements except for the exact middle date (which is what the median actually is, mathematically speaking). Is there something wrong with my formula that prevents me from getting any date between the two values?

    Formula: =IF(A1=MEDIAN($E$1:$F$1),»YES», «NO»)

    Thanks in advance

  51. amal says:

    Hi,

    I need help:

    A2 contains name of staff
    C2 contains his weight
    I need to fill D2 with Lean, Fit, Fat or Obese base on which range his weight fits in based on below grid:
    50-60: Lean
    60-70: Fit
    70-80: fat
    80-100: obese

  52. Jesus Rodriguez says:

    Is there a list of the different symbols and what they represent, or what function they have when used in a formula? Example: = (equal to), < (greater than), etc.

    Actually, what I’d like to know, it’s if there is a symbol that represents “between”. Let’s say I want a formula like this: =IF(A1betweenA2andA3,”Yes”,”No”).

    Thank you in advance,
    Jesus R

  53. Jesus R

    There are only a few symbols useable in this context

    X > Y, X Greater than Y
    X < Y, X Less than Y
    X = Y, X equal to Y

    They can be combined
    X >= Y, X Greater than or equal to Y
    X <= Y, X Less than or equal to Y

    X <> Y, X not equal to Y

    you can often use other Excel functions to make other logic

    or(X=Y , Z=A), X=Y or Z=A will force this to be true
    and(X=Y , Z=A), X=Y and Z=A both have to be True for this to be True

    The above can be used in numerous ways to create quite complex logic

  54. Shishir says:

    There are a problem
    I requered to the formula for example below
    A1 B1 C1
    A+++ A +++
    A++ A ++
    A+ A +
    A A

    Kindly suggest me the formula for that in write segment.

    Thanks

  55. @Shishir
    .
    Not sure but try the following
    B1: =Left(A1,1)
    C1: =Right(A1,Len(a1)-1)
    Select B1 + C1
    Copy down

  56. aa aa says:

    Hello, nice topic.. It’s clear to use between value when there s just one.. how d you determine where the values in a range fall between in another range.. lets say I have a list goes like
    1-5 100
    6-13 200
    14-32 300
    what I want s to expand the list like
    1- 100
    2- 100

    6- 200

    Guess first I need to find where the tax number fall between , then I ll reference to the cell just aside of that range.

    Need help, thenks in edvance

  57. neha says:

    Dear All,
    Plz help in formating the «if formula» in excel of the below condition
    Less than 95% = 0
    95.01% to 97.5% = 0.06
    97.51% to 100% = 0.12
    100.01% to 102.5% = 0.18
    102.51% to 105% = 0.25

  58. @Neha
    Try this:
    =IF(A1<=95%, 0, IF(A1<=97.5%, 0.06, IF(A1<=100%, 0.12, IF(A1<=102.5%, 0.18, 0.25))))
    .
    or this odd one
    =CHOOSE( MIN( INT((( A1-95.001%)/2.5%)) + 2,5), 0, 0.06, 0.12, 0.18, 0.25)

  59. How about adding an else statement to this
    =if(AND(A1>=A2,A1<=A3),»Yes», «No»)

    So if cell A1 is empty I the result will be a blank cell or an entry of my choosing.

  60. Here is a better way of explaining what I’m looking for
    Can you add an ELSE statement to this: =if(AND(A1>=A2,A1<=A3),»Yes», «No»)

    What I need is to be able to return a null value if cell A1 doesn’t have any data in it yet

  61. @Jmichuck
    =IF(A1<>"",IF(AND(A1>=A2,A1<=A3),"Yes", "No"),"Null")
    Retype all » characters

  62. neha says:

    Dear hui,
    I have tried your suggested logic but it didn’t work.Err.502 come while putting it.Plz.help me out

  63. @Neha
    Did you try:
    =IF(A1<=0.95, 0, IF(A1<=0.975, 0.06, IF(A1<=1, 0.12, IF(A1<=1.025, 0.18, 0.25))))

  64. neha says:

    hai Hui Thanxxxxxxxxxx.a lot dear……….it works.With this i finally complited my report which need to submit by tomorrow.Thanks once again.

  65. Thank you, but there seems to be an error in the formula.

    By the way, thank you so much for your services. This will impress the boss for sure.

  66. What do you mean by «Retype all ” characters»?

  67. oK you literally mean they have to be re-typed. Strange but it worked. Thank you very much

    • Sometimes WordPress converts the » characters to something that looks like a » but isn’t
      When you copy/paste to excel, excel doesn’t understand what those » look-like characters are
      And returns an error

  68. baum schausberger says:

    problem. how to use ABS and IF here: (9-5)/2+9=11 but 11>9 so I need 11-9 = good. how to do this.

  69. =if((9-5)/2+9<11,11-((9-5)/2+9),(9-5)/2+9) )

  70. Pradhish says:

    nice use of median. just what was i looking for, but i would appreciate if you could extend the number of rows it checks for inclusion. for eg in the sample data you posted,
    http://chandoo.org/img/f/between-formula-in-excel.png

    i wish to find out if «22» falls under range B2:C9. (Assuming «Value» is in cell A1). kindly help me with this since the only solution i can think of is using nested functions which makes it a monster formula..

  71. thnks hui. now I got your formula =sqrt(A1^2+A2^)-1-IF(sqrt(A1^2+A2^2)-1>53,53,0) work good, now if it is possible, beside this I really need also in the same formula to use ABS value and ROUND, because I got negative numbers, and so many decimals, so to eliminate I need to use those functions, thank you.

  72. neha says:

    @ Dear Hui
    there is a condition —
    15001 — 20000 = Grade «C»
    20001 — 50000 = Grade «B»
    50001 — 100000 = Grade «A»
    100001 & Abiove = Grade +A
    I have used your earlier formula with some modification i.e.
    =IF(A2<=20000,»c»,IF(A2<=50000,»b»,IF(A2<=100000,»a»,»a+»)))
    it works but I also want with the change of grade colour of the cell is also changed for eg Grade A comes with green backgroung & grade C comes with Red background & like wise.
    I tried conditional formatting but yet no appropriate result comes.
    Plz help.

  73. @Neha
    You will need to add 3 CF Rules and have them in the right order
    Select your Range I am assuming B2:B10
    Enter 3 CF Rules using formulas
    CF1: =$A2<=20000 CF Color X, Stop If true Yes
    CF2: =$A2<=50000 CF Color Y, Stop If true Yes
    CF3: =$A2<=100000 CF Color Z, Stop If true Yes
    Now apply this
    Apply a Default Color which will be applicable if the score is Greater than 100000
    That should be it
    Make sure that the 3 CF’s are in the order above, you can shift them up/down once entered

  74. Shishir says:

    Dear all
    I want to
    A B C
    BP03/44/00/12FC BP03/44/00/12 FC
    BP03/44/00/21SF BP03/44/00/21 SF

    Kindly suggest me how i will do by using the formulas.
    Thanks & Regards
    Shishir

    • B1: =Left(A1,Len(A1)-2)
      C1: =Right(A1,2)
      Copy both down

  75. Sonal says:

    Dear all
    on dated 10/01/1012i make a excel sheet. If after the day like tomorrow or day after tommorow somebody modify any cell indicate in a seperate colour which cell somebody modity. which formula i use for that. Kindly suggest me.
    Thanks

    Sonal

  76. walt says:

    Vlookup is an excellent formula to find «between» values:

    Table:
    Value Multiplier
    Column A Column B
    0.00001 0.5
    4.826369861 1
    9.652739721 1.5
    14.47910958 2
    19.30547944 2.5
    24.1318493 3
    28.95821916 3.5
    33.78458902 4
    38.61095888 4.5
    43.43732875 5
    48.26369861 5.5
    53.09006847 6

    Lookup value (cell A1) -> 3
    vlookup(A1,$A$1:$B$12,2,TRUE) — will result in 0.5.

    Hope this helps.

  77. Gaurav says:

    Hi, can someone help me how to write this function in Excel.

    There are 100 rows of 3 diferent numbers (so, 100 rows, 3 columns, C1, C2, C3).
    I have to do the following:
    If C1, C2 and C3 are equal to 2, 4, and 5 respectively, then answer should be 1
    If C1 and C2, or C2 and C3, or C3 and C1 are able to match 2&4, or 4&5 or 5&2 respectively, [i.e, if two of the 3 entries match correctly] then answer should be 0.5
    If none of C1, C2, C3 match 2,4,5 respectively, then answer should be 0.

    Thanks

  78. Jessie says:

    I’m a complete noob at Excel Formulas. I’ve been trying to increase my knowledge of excel but I can’t seem to find how to create this formula.

    I have an employee that works from 6:00am to 2:30pm. She takes a 30 minute lunch and has two paid 15 minute breaks. At the end of the day she has 7.5 hours of productivity. The problem is some days she works in as many as 8 different queues. I have to record those times in each queue but at the end of the day her hours should not be more than 7.5. In a perfect world she’d work in one queue for 6-2:30pm and a simple formula would work to get 7.5 hours but that’s not the case. She may work 2 hours in one queue, 1 in another, 3 in another and 2 in another. How do I factor her breaks and her lunch in my formula. She goes to break at 8:30am, lunch at 12:00-12:30 and last break at 1:45.
    Also some other factors, employees working 4-6 hours get on break. 7 hours a lunch and break, 8-12 hours is lunch and two breaks. employees can’t work more than 12 hours in a day. I hope someone can help. I’m lost. Here’s one formula I was using. but sometimes my hours go above 7.5. =IF(SUM(D23-C23),(24*MOD(D23-C23,1.25)-LOOKUP(24*MOD(D23-C23,1.25),{0,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9

    • Jessie says:

      sorry, I left that formula incomplete.

      =IF(SUM(D23-C23),(24*MOD(D23-C23,1.25)-LOOKUP(24*MOD(D23-C23,1.25),{0,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10},{0,0.5,0.5,0.5,0.5,0.5,1,1,1,1,1,1,1,1})),»»)

  79. I am using this formula have a formula in cell E1 =IF(A1″»,IF(AND(A1>=C1,A1<=D1),»PASS»,»FAIL»),» «)
    When I ener a value in cell A1, I get a pass/fail or null returned in cell E1.
    I would like to also place a value into B1 but have that take priority over A1.
    So If I was to only have an value in A1 the formula would work as stated above. If I was to place a value in Cell B1 it would then disregard cell A1 and return pass/fail based on input in B1.

    Hope that makes sense. Thank you

  80. @Jmichuck
    like:
    =IF(B1<>"","B1 not empty" ,IF(A1 ="", IF(AND (A1>=C1, A1<=D1), "PASS", "FAIL"), ""))

    you will have to retype all the » marks

    • Hui,

      Thank you but not quite correct. I would like the formula to take the value of A1 & B1 and evaluate if they fall between the values of C1 & D1. If so then I would get either a PASS/FAIL result. If there is a Value in B1 then it would disregard the value in A1. If both A1 and B1 are Empty then the cell with the formula would remain empty.

      Thank you so much for looking into this. I really appreciate it.

      -Chuck

  81. jmichuck,

    Here’s one way:


    =CHOOSE(1+(INDEX(A1:B1,(LEN(B1)>0)+1)>=C1)*(INDEX(A1:B1,(LEN(B1)>0)+1)<=D1)+(LEN(A1&B1)=0)*2,"Fail","Pass","")

    …or in the spirit of Chandoo’s article:


    =CHOOSE(1+(INDEX(A1:B1,(LEN(B1)>0)+1)=MEDIAN(INDEX(A1:B1,(LEN(B1)>0)+1),C1,D1))+(LEN(A1&B1)=0)*2,"Fail","Pass","")

    Regards,
    Daniel Ferry
    Excel MVP

    • Daniel,

      Thank you very much. That worked out perfectly

    • OK one thing. If cells A1 thru D1 have no values, I would like to see the cell with the formula to be null/empty. Currently with the formulas above I will get #VALUE or #REF!

      Thanks again

      • Sorry the second formula returns #NUM! not #REF!

      • jmichuck,

        To satisfy this further requirement is easy for the first formula (we just add another null at the end:


        =CHOOSE(1+(INDEX(A1:B1,(LEN(B1)>0)+1)>=C1)*(INDEX(A1:B1,(LEN(B1)>0)+1)<=D1)+(LEN(A1&B1)=0)*2,"Fail","Pass","","")

        You would need to trap the condition with an IF() or IFERROR() wrapper on the second formula, so for your requirements I’d go with this formula directly above, even though I made the MEDIAN() suggestion to Chandoo in the first place!

        • Looks like its working perfectly. Thank you!

  82. Murray says:

    Since Excel stores date/times as numbers, using median will only work if the times you are actually in the range.

    This stumped me for a bit.

    If I want to check that «01/12/1972 9:15AM», is between «9:00AM» and «10:00AM», the median formula won’t work. You need to check if its between «01/12/1972 9:00AM» and «01/12/1972 10:00AM»

    Does anyone have an idea on how to quickly check if the date:time is between two times (with no date).

    • @Murray
      Use median with the times
      but instead of the date use
      Date-Int(Date)

      • Murray says:

        @Hui

        Can you give an example? The date:time is in one cell.

      • Murray says:

        Oh, thanks Hui. I see what you mean now. Thanks again.

        • =MEDIAN(TIME(9,0,0),A1-INT(A1),TIME(10,0,0))
          or
          =IF(MEDIAN(TIME(9,0,0),A1-INT(A1),TIME(10,0,0))=A1-INT(A1),TRUE,FALSE)
          the second will return True if it is between 9-10am

  83. In excel 2010 I need a formula If a cell is blank > 21 days send an email.

    Many thanks in advance!

  84. Tara says:

    I find this string very interesting and helpful. I am not sure I followed all of it, so if this has already been answered, I apologize.

    Here is what I have:
    Cell A1: =Today()
    Column B: List of Dates by Week ending — Begins with 2/19/12
    Column E: Percent completed

    I need a formula that will look at cell A1, determine which cell would apply in column B, and then populate the percentage from column E.

    Any help would be greatly appreciated.

    • Tara says:

      I realized that I can do this with a simple VLOOKUP. So, based on the information in my previous post:

      =VLOOKUP(A1,B2:E52,4)

      In the past, I had only used VLOOKUP to find exact matches, so I did not realize that for the range_lookup I could either use TRUE, or omit the criteria, and find the closest match.

      Sometimes the simplest things elude us, so I just thought I would share this for anyone else who might be searching.

  85. shishir says:

    HI,
    A B C D
    1 ABC Y

    2 ACB Y Y ACB

    3 CAB Y

    4 CBA Y Y CBA

    5 BCA Y Y BCA

    I get THE VALUE OF COLUMN D BY USING IF, AND & INDEX FRMULA.THE PROBLEM IS I WANTED TO CONTINUE THE VALUE OF D LIKE WITHOUT ANY BLANK IN ROW (D1=ACB; D2=CBA; D3=BCA). KINDLY SUGGEST WHICH FUNCTION I USE.

  86. Krystian says:

    Hi

    I wonder if someone could help me with this. How can I check if time beetween a and b fall in between the time c and d?

    Thank you in advance

    Krystian

  87. Krystian says:

    Following previous question: to be more specific, I need to check whether the time between 09:17:00 and 09:58:00 falls between the time 09:35:00 and 09:45:00?  
    Any help would be really appreciated
     

  88. where here, and how, is possible to upload a vba code, I need to add some condition more to the code but I don’t know how to do it.

  89. Syl says:

    I have two excel documents I’m trying to use a look up formula to see compare the peoples names on both of the documents but I can’t seem to have any luck. I have used vlookups before and never had to dealed with text. any help will be appreciate it! and just I’m new on excel.

  90. I’d like to use conditional formatting to highlight the rows where today’s date falls between various dates in a column but all those different dates need to be the range of plus 6 weeks.
    Am I on the right tack with this?
    CF1:=(today’s date=MEDIAN(DATEfirst cell/+DAY(42)CF color yello, stop IF true yes
     

  91. sixseven says:

    THis trick just saved me a ton of time.  I used absolute references for two of the numbers instead of a range.

  92. Rick January says:

    I want to use a conditional formula as follows.  If the result of a calculation produces a number less than -0.3 return a value.  If the number is between -0.3 and +0.3 return a second value.  If the number is greater than +0.3 return a third value.  I tried this formula
    =IF(E25<-0.3,»corrosive»,IF(E25>0.3,»scaling»,»balanced»)) and variations

    However, it returns «corrosive» even if the calculated number is -0.3 and «scaling» when the number is +0.3. 

  93. Boppa says:

    Hi All,

    I am trying to find formula for the below scenario.

    I have a object id and start date in spread sheet 1 and object id, 3 start date and 3 end dates for the same object in another spread sheet. I want to findout for which record in spread sheet 2 the start date of the spread sheet fall inbetween.

    Sheet 1

    53205649
    8/3/2012

    Sheet 2

    53205649
    7/1/2012
    12/31/9999

    53205649
    7/1/2011
    6/30/2012

    53205649
    7/31/2010
    6/30/2011

    Any help is much appreciated.

    Boppa

  94. Nitesh says:

    Guys, I work in middle east & they have two calendars here.. one islamic calendar (lunar one) & second is Gregorian. I need to know if any specific date falls between two dates, then it automatically converts in islamic month/ date. I have already made a calendar which have first & last dates (gregorian dates) of any islamic month. Can anybody help me??

    Thanks a lot in advance.

  95. Alam says:

    hi. it worked just like charm..
    but applying it seems it works only with three columns….for example
    column 1 (data)
    column 2 data
    column 3 (data)
    column5  (value)

    If(column5=median(column1,2,3),»yes», ‘no’)

    than this formula doesnt work…
    do u think u can find anyothe way

  96. Juls says:

    Hi there,

    I have tried your formula for a project plan. Basically, if the date at the top of the row is equal to or inbetween a start or end date (located in the first two columns), I want it to write «YES» into the calendar — so I know a task is running on that date. Kind of like a Gantt chart.

    However, this formula does not recognise that the 2nd of October is between the 1st and the 5th, and no formula I tried so far recognised the 1st is between the 1st and the 5th.

    Any ideas?

  97. […] Click here for more Excel home works, quizzes & challenges. Clue: Click here for a clue. Got […]

  98. Tan says:

    The conditional formatting does not work along with the AND function in Office 2007. Is this only for 2010?

    • @Tan
      I can confirm that both Conditional Formatting and And() functions work in Excel 2007, 2010 and 2013.

       
      If you have a specific issue or problem post a question at the Chandoo.org Forums:  http://chandoo.org/forums/?new=1

  99. GatesIsAntichrist says:

    Bravo! I simply could not make it to the end of all the posts above so forgive me if already covered:

    Below I will show that
    — the contiguous sequence A1,A2,A3 is not required, neither row-wise or column-wise.
    — Furthermore, A1 can be a formula, not just a cell.
    — So can A2 and A3!

    So you can hardcode 95% and 105% for A2 and A3; or Make A2 98% of something, etc.

    Assuming notation X for one general cell address (or formula!) and Y and Z for the pair to go between where Y <= X <= Z,
    =if(X=median(X,Y,Z),»yes»,»no») or minimally
    X=median(X,Y,Z)

    Example: =if(C3-C2=median(C3-C2,$E$1,$F$1),»yes»,»no»)
    where $E$1 is 95 and $F$1 is 105

    This capitalizes on the characteristic of ranges that you can build ranges noncontiguously with commas. You aren’t legally bound to that colon, you know, ha ha.

    1. Correct me if I was imprecise about endpoint inclusion.
    2. I saw some concern above about negative numbers. I have not tried to test that, much less an exhaustive bulletproofing.
    3. floating point «epsilon» issues may still apply.
    4. Tested only with XL2003 (because you’re crazy to use any later disastrous version, unless forced to do so)

  100. Mark R says:

    Could somebody help me with the below formula?
    I basically want it to sum column D but based on the criteria of column C……..i’m trying to ask the formula to look between codes 50000 and 60000……but this formula doesn’t work for me — what can I use instead of median to look between these codes?

    =SUMIFS(D8:D15,C8:C15,MEDIAN(50000:60000))

    Many thanks in advance!

  101. Clinton says:

    Just wanted to say thanks so much for the tip on using Median. Saved me a lot of extra typing. Was working on a list of unit counts referencing a tiered pricing schedule. I utilized the following and it worked like a charm even though the counts and unit price schedule were in two different worksheets. Cheers!
    =IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$3:$C$3),Sheet3!$D$3,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$4:$C$4),Sheet3!$D$4,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$5:$C$5),Sheet3!$D$5,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$6:$C$6),Sheet3!$D$6,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$7:$C$7),Sheet3!$D$7,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$8:$C$8),Sheet3!$D$8,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$9:$C$9),Sheet3!$D$9,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$10:$C$10),Sheet3!$D$10,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$11:$C$11),Sheet3!$D$11,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$12:$C$12),Sheet3!$D$12,IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$13:$C$13),Sheet3!$D$13,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$14:$C$14),Sheet3!$D$14,(IF((B2+C2/5)=MEDIAN((B2+C2/5),Sheet3!$B$15:$C$15),Sheet3!$D$15,0))))))))))))))))))))))))

  102. Sumeet says:

    Just a note of thanks. Due to this thread was able to solve a issue very quickly

  103. JAYANT says:

    =IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,IF(A2=15, «OK», «Not OK»,)))))))))))

    • Not OK!

      Hi Jayant.. is this supposed to be a question? If so, please note that the formula gives an error.

  104. =(A1-A2)*(A1-A3)<=0
    or
    =(A1-A2)*(A1-A3)<0

    • @Kirill.. good idea. Thanks for sharing.

  105. Magda says:

    Hi,

    I need help.

    I have 2 tables;

    1) Dates Column A and prices column B
    2) Date ranges column M and prices column Q

    I need a formula which will do the following
    — Identify if date in column A falls within the rangefrom column M
    — If the answer is positive then I need a price from column Q to deduct a price from column B

    Any ideas?

    Thanks

  106. ericb says:

    the median stuff saved my bacon. you rock!

  107. lucyolsen says:

    =(A3=MEDIAN(A1:A5))*(COUNTIF(A1:A5,A3)=1)

    • lucyolsen says:

      Sorry, I mean
      =A1=MEDIAN(A1:A3)*(COUNTIF(A1:A3,A1)=1)

      Also, if you put () around the first statement, it returns a 0 or 1 rather than true/false.

      • lucyolsen says:

        …that doesn’t work for testing the number 0.

        but these should work for an entire range of numbers, not just 2:
        =MIN(A3:A16)=A1)
        =MIN(A3:A16)A1)

        • lucyolsen says:

          try again…

          [=(MIN(A3:A16)=A1)]
          [=(MIN(A3:A16)A1)]

          • lucyolsen says:

            one more time (damn html tags)

            {} are used in place of less/greater than

            =MIN(A3:A16){=A1*(MAX(A3:A16)}=A1)
            =MIN(A3:A16){A1*(MAX(A3:A16)}A1)

  108. Richard K says:

    This helped me figure out the basis to a formula to tell me if a number was between a set of numbers OR if it exceeded the top end of the numbers… Excel would not except the formula using the MEDIAN, probably since you are actually evaluating for three conditions.

    =IF(AND($D17>5000,$D1710000), «Excessive», «No»))

    Thanks for the assist on this =D

    • @Richard
      Try: =IF(MEDIAN(5000,$D17,10000)=$D17,»No»,IF($D17>10000,»Excessive»,»Lower»))

  109. Prasad TR says:

    I have situation, where Find number in between A:A to B:B, if find the number then put the value of Cell column of «C»

    Ex:-

    what to find the number 24

    Column A B i have numbers
    A — B — C
    1 — 5 — ram
    8 — 10 — Ramesh
    18 — 20 — David
    23 — 31 — Abdul

    Out put / Answer = Abdul
    Please suggest.

    • @Prasad TR
      =Vlookup(24,A2:C5,3)

  110. Gigi says:

    If number in cell M11 is between 500 and 1000 true value «DFG» but if the number is between 1001 and 1500,true value «ABC» but if the number is between 1501 and 5000, true value «ERT»

    • @Gigi
      You could use something like:
      =IF(B2<1000,»DFG»,IF(B2<1500,»ABC»,IF(B2<5000,»ERT»,»Other»)))
      or
      =IFERROR(CHOOSE(INT(B2/500),»DFG»,»ABC»,»ERT»,»ERT»,»ERT»,»ERT»,»ERT»,»ERT»,»ERT»,»Other»),»Other»)

  111. Daniel S. Crisan says:

    I have a relatively simple question (i assume) but due to the fact that I am an Excel newbie, it is relatively challenging for me.

    Let us say that I am using 2 cells. Cell A1 & Cell A2

    I want to be able to input any random number from 0-665 in cell A1

    If the number in A1 is 15 but 20 but 30 but 50 but <66, I want cell A2 to show me 6.

    So on and so forth….

    I appreciate any help that i receive!

    Sincerely,

    Dan.

  112. Helpseeker says:

    Hi there, am looking to use a condition in conditional formatting and need to ABS and a formula fulfilling this condition. Please advise. Many
    thanks in advance.
    «if the values are between -0.25% and 0.25% then yellow»

  113. I need 3 date conditions met:
    NOT STARTED, STARTED, COMPLETE for dates:
    A2 no date, B2 no date, C2 no date = Not Started
    A2 date, B2 date, C2 no date = Started
    A2 date, B2 date, C2 date — Complete

    Can you please help me? Thanks!

  114. Robbee T says:

    Thanks for the help. I’ve been looking for a way to do this formula.

  115. HelpSeeker says:

    if the value of school is 72 and class is 54, what will be the value of teacher?

  116. razak says:

    I have made in Excel sheet table of items location, some items are repeated in more than one location, how can i use lookup formula to find those items locatons?

  117. razak says:

    Item code Description LOC Bin Sys
    Qty
    T82133008 SOCKET WRENCH BI-HEX. DIN 3120 SQUARE DRIVE: 1/2″ SIZE: 8 MM. 108 D12-3 8
    T82133010 SOCKET WRENCH BI-HEX. DIN 3120 SQUARE DRIVE: 1/2″ SIZE: 9 MM. 108 D12-3 8
    82133013 SOCKET WRENCH BI-HEX. DIN 3120 SQUARE DRIVE: 1/2″ SIZE: 10 MM. 108 D12-3 8
    82133013 SOCKET WRENCH BI-HEX. DIN 3120 SQUARE DRIVE: 1/2″ SIZE: 10 MM. 108 D12-3 2
    82133025 SOCKET WRENCH BI-HEX. DIN 3120 SQUARE DRIVE: 1/2″ SIZE: 11 MM. 108 D12-7 9
    82133025 SOCKET WRENCH BI-HEX. DIN 3120 SQUARE DRIVE: 1/2″ SIZE: 11 MM. 108 D12-7 3
    82133037 SOCKET WRENCH BI-HEX. DIN 3120 SQUARE DRIVE: 1/2″ SIZE: 12 MM. 108 D12-3 13
    82133037 SOCKET WRENCH BI-HEX. DIN 3120 SQUARE DRIVE: 1/2″ SIZE: 12 MM. 108 D12-3 2

  118. Ahmed Fathy says:

    i will give you a very quick example for what i want

    i have a dead line date 20/2/2015 ( thats the date in cell )

    if Today date is before it within 2 day ( 18/2/2015 )

    i want cell to be fill with another color and font

    if not then i need it to be the same as rest

  119. Havanai says:

    Why isn’t there a simple BETWEEN function like there is (or was) in FoxPro? To check to see if the value in field A3 is between .125 and .500 you’d write IF(BETWEEN(A3,.125,.500),»True»,»False»). Simple and straightforward.

    I want to generate a random number and check to see if it is between two other numbers. Using Microsoft’s FoxPro syntax it would be IF(BETWEEN(RAND(),.125,.500),»True»,»False»). But despite it also being a Microsoft product, there seems to be no such BETWEEN() function in Excel. Crazy.

  120. Feccc says:

    A1=5
    B1=3
    C1=10

    =IF(AND(A1>B1,A1<C1),»YES»,»NO»)

  121. Linda says:

    Hello and thank you in advance for your help. I have a monthly bonus excel report which provides me a list of all employees who are subject to bonus changes. One column contains the date the bonus change was implemented as follows:

    1. Mark Jones — bonus target % on 02/05/2015
    2. Mary Freeze — Bonus type change on 02/15/2015
    3. John Camden — Bonus target % on 02/27/2015
    4. Freida Jones — Bonus type change on 03/03/2015
    5. Sam Carrera — Bonus target % on 03/16/2015

    However, our Bonus plan rule states, any change on/or before the 15th of the month will default to the 1st of the applicable month.

    Any change after the 15th, will default to the 1st of the following month. So, Mary Freeze bonus target change will take effect on 02/01/2015 and Sam’s will be effective 04/01/2015.

    How can I create a formula that would auto populate the effective date based on these rules? Is it possible to create this under and IF/OR = X statement?

  122. Hi and thank you in advance for your help. I have gone through all of the replies to see if my issue was answered but I can’t find anything. I have a time that I want to see if it falls between two other times. The formula =A1=MEDIAN(A1:A3) works for most of the times except for the following example… does 11:15 PM fall in between 8PM and 8AM. The answer the formula returns is NO, but it should be Yes. Any help would be appreciated!
    Thanks.

    • Hi Stephen,

      In Excel there are no such thing as 8AM or 8PM. So, when you write 8AM in cell, it really is 8AM of January 0, year 1900.
      So in your case, 11:15 PM check is failing because 8AM is before 11:15 PM.

      To overcome this, you can try below approach.

      Assuming A1 is the time you want to check, A2 & A3 contain start & end times,

      =A1 = median (A1, A2, A3 + AND(HOUR(A2)>12, HOUR(A3)<12))

  123. Tolga says:

    Hi,
    This is what I am trying do
    if value on A1 between
    0-154 A2 0
    155-462 A2 -1
    463-770 A2 -2
    771-1049 A3 -3

  124. Adam says:

    This isn’t working for me.

    I’m trying to say whether a project that has a start and an end date is in progress in each week commencing.

    E.g. start 14/08/15 end 25/08/15

    The table has weeks commencing 03/08/15, 10/08/15, 17/08/15, 24/08/15, 31/08/15

    What I want to return is «No», «Yes»,»Yes», «Yes», «No» (in cells in the row below)

  125. Karlien says:

    Hi,

    I have a question:

    I have amounts ranging from 10-45

    I would like to make a rule that if it is between 10-24 it should show 7.5, if it is between 25-38 it should show 10 and if it between 39-45 it should show 13.

    How do I do this, I tried the IF formula, but I’m struggling.

    TIA

  126. Joe says:

    Hi,
    I tried this in Excel 2010
    =IF(1=MEDIAN(0,3),»Y»,»N»)
    and the result is N.
    Shouldn’t the correct result be Y
    What did I do wrong?
    Please advise.
    Thank you.

    • @Joe
      Select the cell with the Formula =IF(1=MEDIAN(0,3),»Y»,»N»)
      Edit the cell and select the part MEDIAN(0,3)
      Now press F9
      Excel displays 1.5 which is the median of the two values
      So 1 NE 1.5 and so the If evaluates the False to be N

      NE = Not Equal

      Median:
      Returns the median of the given numbers.
      The median is the number in the middle of a set of numbers.

  127. joe says:

    @Hui

    Thank you for your quick reply.

    I think I may have misunderstood about median and this part of the article — «Lets say you have 3 values in A1, A2 and A3. And you want to find out if A1 falls between A2 and A3.»

    For example, if I want to find out if 1 is between 0 and 3,

    then I tried =IF(1=MEDIAN(1,0,3),»Y»,»N»), the result is Y.

    Is this the correct formula?

    Thank you for you advice.

    • @Joe

      I can only comment on the question posted and your example had 2 values not 3

      To test if A1 is between A2 & A3
      =IF(A1=MEDIAN(A1, A2, A3),»Y»,»N»)

      Using the formula =IF(A1=MEDIAN(A2, A3),»Y»,»N»)
      will only work if A1 is exactly at the midpoint of A2 & A3
      If
      A1 = 3
      A2 = 2
      A3 = 10

      Median(2,10) =6
      A1 NE 6

      Median(2,3,10) = 3
      A1=3

      NE = Not equal

  128. Sarita says:

    Can you please help me with the below conditions using IF or Nested IF formula?

    A1-67%, A2-120%, A3-157%

    150%

    Should i change it to 99.99% in place of 100%? or 149.99% for 150%??
    So in B1 i want to the value using if formula that if A1 is less than 75% B1 should display <75%, if value in A1 is between 150%,»>150″,IF(A1<=150%,»100%-150%»,IF(A1<100%,»75%-100%»,IF(A1<75%,»<75%»,IF(A1=0%,»0″,IF(A1=»»,»»))))))

    I am not sure what am i missing here, its giving !00%-150% whereas the value in A1 is 96% so it should display 75%-100%
    Can you please help at the earliest??

    • Sarita says:

      Please provide me the formula you think will work

    • @Saita
      If(A1=»»,»»,if(A1 lt 75%,»lt 75%»,if(A1 lt 100%,»75%-100%»,if(A1 Lt 150%,»100%-150%»,»gt 150%»))))

      LT = Less Than sign
      GT = Greater Than sign

      If you copy this from here change all the » to » signs

      100% will show as 100%-150% as it is not less than 100% it is less than 150%
      If you want it to show up as 75%-100% change the formula to:
      If(A1=»»,»»,if(A1 Lt= 75%,»Lt 75%»,if(A1 Lt= 100%,»75%-100%»,if(A1 Lt= 150%,»100%-150%»,»Gt 150%»))))

  129. Sarita says:

    Hi Hui,

    Thank you sooooooo much..it worked…. 🙂

  130. Carrie says:

    Need a formula that strings 2 formulas together:

    A2 has a value of 0
    A3 has a value of 5

    A1 has a value that falls between A2&A3 it will equal 40

    B2 has a value of 4
    B3 has a value of 13

    If B1 falls between B2&B3 it will have a value of 25

    B1

  131. Meghna says:

    HI

    i want to put an equation if A = (between 25 to 30) then this formula will apply, if not another formula
    can u help me how can i do it?

    • @Meghna

      Lets assume that your talking about cell A2
      In A3 or elsewhere: =If(And(A2>25, A2<30), «A», Other formula goes here)

      • Meghna says:

        Thank you so much

  132. PK says:

    Column A | Column B Column C | Column D
    —————|————— —————-|————
    0000000000001 000000000999 000000000001 032258064500
    0300000000010 031000001999 032258064500 064516129030
    0620000010010 080000010999 064516129031 096774193550

    I need a script or a formula to determine if the Range Between Column (A & B) falls between the Range of Column (C & D) to highlight them certain color.
    If range overlaps multiple range to state the overlap.

    Thanks!

    • @PK
      Sorry I was travelling when you posted this and missed it

      Select the Range A1:B3
      Conditional Format
      New Rule
      Use a Formula =AND($A1<=$D1,$B1>=$C1)
      Apply a Format

  133. Debbie says:

    I’ve been searching for a formula that seems like it would be very simple, but have been unable to find. I want a certain cell to do this: if anything at all is typed into the cell, it will return «Yes.» If the cell is left blank, it would remain blank. So, no matter what is typed into the cell, it will simply say «Yes.» Is this possible?

    • @Debbie
      Yes it is

      Select the Cell/s
      Ctrl 1 or Right click and Format Cells
      Number, Custom
      Apply a Custom Number Format of «Yes»;»Yes»;»Yes»;»Yes»

  134. Debbie says:

    Thank you! That did it.

  135. Kurt Kramer says:

    I want to generate a random number between 1 and 10000, maybe using this function: =RANDBETWEEN(1,10000)

    Then, in that cell, if the randomly generated number is between 1 and 1500 I want to populate the cell with «Empty», and if it’s between 1501 and 7500, I want «Small», and if it’s between 7501 and 10000, I want «Large».

    Can someone come up with a formula to do that?

    Thanks.

    • @Kurt

      In the cell enter =Randbetween(1,10000)

      Then apply a Custom Number format of:
      [<1501]»Empty»;[<7501]»Small»;»Large»

      If you really want a formula you can use:
      =IF(RANDBETWEEN(1,10000)<=1500,»Empty»,IF(RANDBETWEEN(1501,10000)<=7500,»Small»,»Large»))

      But you should note that the second Randbetween will be using a different number than the first

      • Kurt Kramer says:

        Hui, Thank you. That’s a good start. But I need more. Your response works for 3 options. I actually need 5 ranges/options. For example:

        8000 then Tony

        Your nested IF-statement won’t work because of the caveat you gave, that each nested RandBetween would be a different number.

        Thanks again.

  136. Kurt Kramer says:

    Accch. Some of my text got deleted upon saving. I need something like this:

    8000 then Tony.

  137. Kurt Kramer says:

    What the hell? I am listing five ranges and options in my text here, but when I post, the first four disappear! Maybe I cannot use the less than or greater than symbols. Try this:

    Accch. Some of my text got deleted upon saving. I need something like this:

    less than 1500 then Bill; between 1501 and 3500 then Nick; between 3501 and 4000 then Phil; between 4001 and 8000 then Fred; greater than 8000 then Tony.

  138. ramkumar says:

    =COUNTIF(H2:H7,LARGE(H2:H7,3))
    it is correct or not

  139. ramkumar says:

    can you please help me the below mentioned formula
    i used this formula but wrongly shows the result

    please help me the formula

    =COUNTIF(H2:H9,LARGE(H2:H9,3))

  140. Craig says:

    I have over 500,000 lines of data I need to determine the fiscal year the shipping date falls between. Here is a brief example of the data. What is the best formula to get this without a long nested if/then?
    Ship Date Fiscal Year Fiscal Year Fiscal Beg. Fiscal End
    1/8/2008 2016 1/3/2016 12/31/2016
    12/30/2007 2015 1/4/2015 1/2/2016
    1/2/2015 2014 12/29/2013 1/3/2015
    1/2/2012 2013 12/30/2012 12/28/2013
    1/1/2011 2012 1/1/2012 12/29/2012
    2011 1/2/2011 12/31/2011
    2010 12/27/2009 1/1/2011
    2009 12/28/2008 12/26/2009
    2008 12/30/2007 12/27/2008

    • @Craig

      It is hard to understand what data goes in which column, so I didn’t

      But assuming the Fiscal year is July 1 to June 30, and it is Named the later year
      eg: 1 July 15 to 30 June 16 is the 2016 Fiscal year
      Then I would use:
      =YEAR(EDATE(A1,6))

      If it is named after the preceding year use:
      =YEAR(EDATE(A1,-6))

      • Craig says:

        The data I provided was supposed to be in columns. First column has all shipping dates that are random and I need to determine the Fiscal year for those dates which is not the calendar date (over 500,000 rows). The next set of columns would have the Fiscal Year, Beginning date, and then Ending Date for that year, in a small area to the right.

    • Craig says:

      The data I provided was supposed to be in columns. First column has all shipping dates that are random and I need to determine the Fiscal year for those dates which is not the calendar date (over 500,000 rows). The next set of columns would have the Fiscal Year, Beginning date, and then Ending Date for that year, in a small area to the right. These are the reference point to determine the fiscal year for the shipping date.
      Here is an attempt to put it in CSV format.
      Ship Date,Fiscal Year,,Fiscal Year,Beg. Date,End Date
      1/8/2008,,,2016,1/3/2016,12/31/2016
      12/30/2007,,,2015,1/4/2015,1/2/2016
      1/2/2015,,,2014,12/29/2013,1/3/2015
      1/2/2012,,,2013,12/30/2012,12/28/2013
      1/1/2011,,,2012,1/1/2012,12/29/2012
      3/30/2015,,,2011,1/2/2011,12/31/2011
      5/8/2008,,,2010,12/27/2009,1/1/2011
      2/1/2010,,,2009,12/28/2008,12/26/2009
      2/1/2009,,,2008,12/30/2007,12/27/2008

  141. Shams Mahallati says:

    I need a formula for this condition:
    Consider the following table:
    Col.T Col.U
    3075 HDU2
    4565 HDU4
    5645 HDU5
    6970 HDU8
    9535 HDU11
    14390 HDU14

    Now I have a value in Cell A1: 3568
    This value (3568) sits between 3075 and 4565. So , I need a formula in cell, say, B1, to return «HDU4». For any value < 3075, I need a return of «HDU2».
    Similarly, if my value in A1 is 6000, I need he formula go to the table above and returns: «HDU8» in cell B1. Because 6000 is 5645
    If my value is 10000, I need cell B1 shows «HDU14».
    If my value > 14390, I need a return of «HDU14».

    I have tried Vlookup and Index formulas, but it does not work.
    thanks. Shams

    In cell A1 I have a value

  142. Jaan says:

    Hi Guys, I’m really stuck and desperately need help with this timesheet that I’m trying to build…

    if worker works between 6am-9pm, the hourly rate is $50.
    if worker works between 9pm-6am next day, the hourly rate is $75.
    if where any hour of the job cuts across both rates, the higher rate of $75/hr will be used for that hour (e.g 8.10pm — 9.10pm = $75)
    the above pro-rated by minutes as well.

    can any kind soul please help me with this formula?

  143. KAILASH CHAVANKE says:

    Dear sir

    following formula is correct

    =IF(28=MEDIAN(K2.B$4:B$140);»VLOOKUP(B6;K2.$C$4:$D$140;2;0)»;»0″)

    Kailash Chavanke

  144. Chriss says:

    Hello,

    Could you please help with formula for following.

    In Formula cell I need to appear a number (price per person), which depend on interval it fits (e.g. between 1-6 person price would be 20 EUR per person, between 7-12 persons — 15 EUR/person, 12-16 persons — 10 EUR/person).

    There is no problem for me to make between formula with one condition, but I do not know how to make it with 3 different intervals.
    Many thanks!

  145. Usman says:

    want to implement following logic in Excel
    F2 = 1/22/2016 2:57:00 PM
    H2 = 1/22/2016

    o If the day in column H is the same as the day in column F:
    If the timestamp in column F is earlier than 8:00, then 8:00 AM on the day in column H
    If the timestamp in column F is after 5:00 PM, then 5:00 PM on the day in column H
    Else, the value from column F
    o Else, 8:00 AM on the day in column H

  146. HarryS says:

    Like the median trick for numbers =
    a vba function that is within 5% of the speed but works for
    strings Dates Numbers = but not
    as

    Function InLH(Vx, Va, Vb, Optional TestAsEq As Boolean = True) As Boolean
    Dim LV, HV
    If Va > Vb Then
    HV = Va
    LV = Vb
    ElseIf Va = Vb Then
    If Vx = Va Then GoTo IsIn Else GoTo IsBad
    Else
    LV = Va
    HV = Vb
    End If
    If TestAsEq Then
    If Vx HV Then GoTo IsBad
    Else
    If Vx = HV Then GoTo IsBad
    End If
    IsIn:
    InLH = True
    IsBad:

    End Function

  147. HarryS says:

    parte copied incorrectly
    If TestAsEq Then
    If Vx HV Then GoTo IsBad ‘GT
    Else
    If Vx = HV Then GoTo IsBad ‘ Gte
    End If

  148. HarryS says:

    It seems to remove «=»

  149. Donovan says:

    Hi Guys

    Is it no possible to have the =if(and formula as a nested formula between a table of 10 different tiers.

    Kindly advise

    • @Donovan

      The answer is yes, but only in Excel versions 2007+

      It is however not recomended

      If you can post a question in the forums and attach a sample file we can probably provide a better, more efficent, solution
      http://forum.chandoo.org/

  150. Paramjeet says:

    HOW IT WILL WORK FOR TEXT VALUES LIKE CHEETAH ,CAT,TIGER

  151. I see you don’t monetize your blog, don’t
    waste your traffic, you can earn extra bucks every month because you’ve got hi quality content.
    If you want to know how to make extra money, search for:
    Boorfe’s tips best adsense alternative

  152. Shuja Abbasi says:

    i want can i check these two values falls (380225 380275 ) falls in bellow mentioned values

    380000 380065
    380065 380100
    380100 380125
    380125 380200
    380200 380225
    380225 380275
    380275 380325
    380325 380800
    380800 380810
    380810 380835
    380910 381000
    381000 381025
    381025 381050
    381050 381065
    381065 381085
    381085 381100
    381100 381600

    • @Shuja

      Assuming your data is in A2:B18
      In C2: =AND(A2<=380225,B2>=380275)
      copy down

  153. Shuja Abbasi says:

    @Hui

    sir i want to sort out the values from two column with the other to column values, that the values falls or overlap or not, just like i mentioned below. and i want value in return answer in one rang column formula, just look at 1st values of column C & D only from 38000 to 38035 is overlapping. please help me i am searching that kind of formula

    (Values) (Values for checking)
    A B C D
    380000 380065 379000 380035
    380065 380100 380225 380275
    380100 380125 380525 380575
    380125 380200 380575 380625
    380200 380225 380625 380800
    380225 380275 380910 381025
    380275 380325 381050 381100
    380325 380800 381100 381600
    380800 380810 381600 381675
    380810 380835 381675 383025
    380910 381000 383025 383075
    381000 381025 383090 383150
    381025 381050 383175 383350
    381050 381065 383350 383700
    381065 381085 383700 383850
    381085 381100 383850 383900
    381100 381600 383900 383975
    381600 381675 383975 384025
    381675 382000 384025 384075

    • @Shuja

      Can you please ask the question in the Chandoo.org Forums
      https://chandoo.org/forums/

      Please attach a sample file with an example of the output you expect

  154. MOHAN k says:

    581.17 581.66 148 48
    581.67 582.46 148 49
    582.47 583.33 149 49

    My lookup value is 581.91 from above data and I need an answer from right side mentioned value of (148 & 49) from column C & D
    finally, I don’t want true or false statement instead of that i want answer of 148 & 49, please help me

    • @Mohan K
      assuming your data is in A2:D4
      =VLOOKUP(581.91,A2:D4,3)
      =VLOOKUP(581.91,A2:D4,4)
      =VLOOKUP(581.91,A2:D4,3) &» & » & VLOOKUP(581.91,A2:D4,4)

  155. Jei says:

    Hi! Can someone help me with writing an Excel «if condition» the say «if cell H3 has «At Risk», then change cell fill to Red. I wrote the following: =If $H$3 ‘At Risk’ ($C$3, colour Red)

    • Hi Jei,

      Welcome to Chandoo.org and thanks for your comment. You need to conditional formatting to do this. Follow below instructions.

      1. Select all cells you want to check.
      2. Go to Home > Conditional Formatting > Highlight Cell Rules > Equal to…
      3. Type «At Risk» as the condition and Click ok

      Click here to learn more about conditional formatting.

Leave a Reply

Days Between Date

There are two formulas to find the number of days between two dates within excel. The first will only yield the number of days and that is the DAYS formula found in the Date & Time button within the FORMULAS tab in the ribbon. Using this simple method, you can find answers for the query on how to find date differences in excel, or else you can use another formula given below.

The 2nd Formula is DATEDIF

It may also be used to find the exact number of days but will also yield the number of months or years between two dates. One very important difference between the formulas is, The DAYS will list the end date first, whereas the DATEDIF range begins with the start date.

Shown below are the two formulas being used to find the exact number of days between August 15 and September 15.

How To Excel Between Two Dates 1

DAYS Formula

It’s written as =DAYS(End_Date, Start_Date) and becomes the quickest and easiest way to find the exact number of days or weeks (divide 7 into the results to get a week count). The dates can be formatted as Short Date (1/1/17) or Long Date (Sunday, January 1, 2017) the formula will work and the results will be the same.

How To Excel Between Two Dates To Change The Format 

The dates quickly go to the HOME tab in the ribbon, find the box and change the formatting with the drop-down menu as shown to the right.

How To Excel Between Two Dates 2

Tip: Make sure the cell that you enter the formula into is formatted to be either General or Number otherwise; it will list the date code for the numeric value. (eg. The above dates will result in 12/29/1900 as the answer until you change the formatting).

The DATEDIF Formula

It’s a slightly hidden formula within Excel and is written as

=DATEDIF(startdate, enddate,“interval”)

The Interval can be either days, months, or years. All accepted codes that may be input as intervals by Excel are as follows:

  •       d= days
  •       m= months
  •       y= years
  •       ym= number of months between two days while ignoring the year
  •       yd = number of days between two dates while ignoring the year

·        md = number of days between two dates while ignoring the year. This is not a recommended interval as it has many issues that result in negative numbers, a zero, or inaccurate results. inaccurate results.How To Excel Between Two Dates 3

Use All Working Integrals And The Same Date Range

Using all working integrals and the same date range gives the best example of how these integrals work within the formula. B2 shows there are 433 days between January 1, 2017, and March 30, 2018, but look at B6, while ignoring the year it results in 88 days between January 1st and March 30th. B3 shows the difference as 14 months and combining B4 & B5 shows the dates are 1 year and 2 months apart.

Finding the exact Years, Months and Days between the two dates is possible with use of the ampersand.

The 3rd Formula

DATEDIF is the 3rd formula to use “y” integral and “ym”. The third is the DATE formula that calculates the differences between two dates in excel and that is the end date and the first day of that month. To combine all three formulas: Enter an ampersand followed by the description in quotations, then another ampersand and the next formula.

Years, Months & Days Formula

You can see that adding “YEARS”, “MONTHS”, and “DAYS” into the formulas tell Excel exactly what the labels should be named within the results (B6). If you want to separate them with commas and spaces enter the commas and spaces into the quotation. For instance, “Years, ”.

Use DATEDIF And NOW As A Countdown

Combining the two formulas creates a continuous countdown towards a specific date. Let’s start a countdown to April 15th of Next year.

=DATEDIF(NOW(),4/15/18,”d”)

The result as of today (8/14/17) is 244 days until the close of tax season next year. Tomorrow the worksheet will say 243 because using NOW as the end date will continuously change the formula to the present day.

Uses Of The DATEDIF & DAYS Formulas

A few uses of the DATEDIF and DAYS formulas could be knowing how many months or days are left on a warranty, allocating depreciation, calculate the age of a company using its incorporation date, and of course as a countdown to holidays.

Factoring In Holidays

Another great function we can use is NETWORKDAYS, what it offers above other approaches is two-fold;

  1. Return number of ‘workdays’ in a period

So, for example, if we want to know the number of working days in a year we can do this:

=NETWORKDAYS(F56, F57)

Excel gives us the result ‘260’

  1. Return number of ‘workdays’ in a period FACTORING in holidays

This is very powerful, especially for budgeting, where we are trying to understand how to budget for contractors/consultants. We know the average person has 4 holidays a year (quite brutal!).

We can set up NETWORKDAYS and use the optional argument:

If we list the holidays separately, we can easily factor them in to the number:

Press  Enter and we get our updated result of 256, a more accurate value of number of days in the year that will be worked, That’s how to excel between two dates.

Like this post? Please share to your friends:
  • Excel interop not closing
  • Excel interop get range
  • Excel interop create file
  • Excel interop column width
  • Excel interop cells value