# How to Use IF Formula with Dates (6 Easy Examples)

While working in Microsoft Excel, there are various formulas to make our work easier. IF formula is one of them. It has a wide range of applications in Excel. The IF function performs a logical test. It returns one value if the result is TRUE, and another if the result is FALSE. In this article, we will illustrate how to use the IF formula with dates. In order to do this, we will go over several examples.

## Overview of Excel IF Function

• Description

The IF function does nothing but test for a specific condition.

• Generic Syntax

IF(logical_test,[value_if_true],[value_if_false])

• Argument Description
ARGUMENT REQUIREMENT DESCRIPTION
logical_test Required This is the condition that will be tested and rated as TRUE or FALSE.
[value_if_true] Optional When a logical test evaluates to TRUE, this is the value to return.
[value_if_false] Optional When a logical test evaluates to FALSE, this is the value to return.
• Returns

The value we supply for TRUE or FALSE.

• Available in

All versions after Excel 2003.

## 6 Uses of IF Formula with Dates in Excel

### 1. Compare Between Two Dates Using If Formula

First and foremost, we will use the IF formula to compare between two dates. At the time of doing this, there can be the following two scenarios.

#### 1.1 When Both Dates are Present in Cells

In this case, both dates are present in cells which we have to compare. In the following dataset,  we have a list of products with their delivery date and deadline. We will calculate the status of the delivery whether the delivery is ‘On Time’ or ‘Delayed’. Let’s see how we can do this: • Firstly, select cell E7.
• Now, insert the following formula:
`=IF(D5>=C5,"On Time","Delayed")`
• Press Enter.
• So, we can see the delivery status of the product mouse is ‘On Time’. • Finally, we will get the final delivery status of all the products. #### 1.2 While One date is Stored in the Formula

Sometimes we will have a dataset like the one given below. Here, the only date we have is the delivery date. The deadline for the delivery is 1-20-22. Let’s figure out the delivery status in the ‘Status’ column of the dataset. • In the beginning, select cell D5.
• Insert the following formula:
`=IF(D5>=C5,"On Time","Delayed")`
• Now, press Enter.
• Here, we can see the delivery status is ‘On Time’ for the product mouse. • After that, drag the Fill Handle tool downwards to cell D10. • Finally, The delivery status of the dataset looks like this. ### 2. IF Formula and DATE Function at The Same Time

In this example, we will use the IF formula and the DATE function together. Like the previous dataset, we will input the delivery status of the products in the ‘Status’ column. Follow the simple steps with us to perform this: • First, select cell D5.
• Type the following formula in that cell:
`=IF(C5<=DATE(2022,1,14),"On Time","Delayed")`
• Hit the Enter key.
• So, we get the delivery status of the product mouse as ‘On Time’. • Now, drag the Fill Handle to cell D10. • As a result, we get the delivery status of all the products in the ‘Status’ column. 🔎 How Does the Formula Work?

• DATE(2022,1,14): Takes the date to compare.
• IF(C5<=DATE(2022,1,14),”On Time”,”Delayed”): Returns the value of the delivery status.

### 3. Excel DATEVALUE Function Wrapped in IF Formula with Dates

In excel DATEVALUE function converts date into text. We can merge this function with the IF formula to calculate dates. For this example, we will go with our previous dataset with a different deadline. Just follow the below instruction in order to do this:

• Firstly, select cell D5.
• Put the following formula there:
`=IF(C5<=DATEVALUE("18/01/2022"),"On Time","Delayed")`
• Then, press Enter.
• Here, we can see the delivery status of the first product mouse is ‘On Time’. • After that, drag the Fill Handle tool. • Finally, we will get the delivery status for all the products in the ‘Status’ column like the below figure. 🔎 How Does the Formula Work?

• DATEVALUE(“18/01/2022”): Consider the date 18/01/22.
• IF(C5<=DATEVALUE(“18/01/2022″),”On Time”,”Delayed”): Returns the value of the delivery status ‘On Time’ if the condition is TRUE. Otherwise gives ‘Delayed’ as output.

### 4. Apply AND Logic & IF Formula with Dates in Excel

Using AND logic along with the IF formula, we can calculate dates in excel. The AND logic returns an output where all the conditions need to be TRUE or FALSE. We will follow our previous dataset with a range of deadlines. Let’s see how can we do this: • In the beginning, select cell D5.
• Insert the following formula:
`=IF(AND(C5>=\$G\$8,C5<=\$G\$9),"On Time","Not In Time")`
• Now, press Enter.
• So, we get the delivery status of the product mouse with AND logic. • Then drag down the Fill Handle tool. • As a result, we get the delivery status for all the products in the ‘Status’ column of the dataset. 🔎 How Does the Formula Work?

• AND(C5>=\$G\$8,C5<=\$G\$9): This part represents two conditions. One is C5>=G8 and another is C5<=G9. \$’ sign keeps the cell reference fixed.
• IF(AND(C5>=\$G\$8,C5<=\$G\$9),”On Time”,”Not In Time”): If the condition is TRUE, returns the value ‘On Time’. Otherwise gives ‘Delayed’ as output.

### 5. Insert TODAY & IF Formulas with Dates

A combination of the TODAY function and IF formula is another approach to count dates in excel. Suppose, we have a dataset of products along with their delivery date. Let us consider the deadline for delivery is today’s date 1-11-22. For you, it will be the date on which you are practicing. Now we will figure out the delivery status of all the products with the following steps: • First, select cell D5.
• Input the following formula:
`=IF(C5<=TODAY(),"On Time","Delayed")`
• Hit the Enter button.
• Here, in cell D5 we get the delivery status for the product mouse in ‘On Time’. • Next, drag the Fill Handle tool to the next cells. • Finally, the delivery status for all the products looks like the below figure. 🔎 How Does the Formula Work?

• TODAY(): This part takes the date of the present day.
• IF(C5<=TODAY(),”On Time”,”Delayed”): Returns ‘On Time’ If the condition is TRUE otherwise give ‘Delayed’ as output.

### 6. Calculate Future or Past Dates in Excel Using IF Formula

In this example, we will check if a date is in a range or not. For example, take today’s day into account. The motive of this example is to check whether the delivery will take place or not within ten days. Let’s see how we can do this: • Firstly, select cell D5.
• Type the following formula there:
`=IF(C5<TODAY()+10,"Within range","Out of range")`
• Then, press Enter.
• Now we can see that the delivery status of the product mouse is within range. The delivery will take place within 10 days from today. • After that, drag the Fill Handle tool. • In the end, we can see the delivery status for all the products in the ‘Status’ column of the dataset. 🔎 How Does the Formula Work?

• TODAY()+10: Takes the date after ten days from the present date.
• IF(C5<TODAY()+10,”Within range”,”Out of range”): If the condition is TRUE returns ‘Within Range’ otherwise gives ‘Out of range’ as output.

## Conclusion
{"ft_lang_label":"__label__en","ft_lang_prob":0.8266139,"math_prob":0.9446878,"size":7798,"snap":"2022-27-2022-33","text_gpt3_token_len":1936,"char_repetition_ratio":0.1575571,"word_repetition_ratio":0.19970414,"special_character_ratio":0.2604514,"punctuation_ratio":0.13602485,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98697704,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-14T15:44:08Z\",\"WARC-Record-ID\":\"<urn:uuid:d9ff3a1e-f5c9-44b2-b9f0-3d8e6106061d>\",\"Content-Length\":\"252798\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b56d1069-4404-4168-8fa0-d44fa4d23af3>\",\"WARC-Concurrent-To\":\"<urn:uuid:b1c0a03d-ec41-4ea4-b5b8-da5ebda11e97>\",\"WARC-IP-Address\":\"172.67.190.223\",\"WARC-Target-URI\":\"https://www.exceldemy.com/if-formula-with-dates/\",\"WARC-Payload-Digest\":\"sha1:HVI5NMETBS6GP3DMWPXAAACF7DFMC576\",\"WARC-Block-Digest\":\"sha1:EUMHQLURYPDR6OMTGJK6UGBKGDREJTBT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882572043.2_warc_CC-MAIN-20220814143522-20220814173522-00537.warc.gz\"}"}