Let’s say you have a date in a cell and want to check if that date is before a particular date. In this case, you need to use the IF function to create a condition to test. And that’s what we will learn in this tutorial, so let’s get started without any ado.
Write Condition to Check If a Date is Before a Date
In the below example, you have a list of dates, and you need to test if these dates are before the date (30-Oct-2023) in cell C1.
- Enter the IF, and in the first argument (condition to test), refer to the cell A2, where we have the date to test.
- After that, enter the lower than operator and refer to the cell with the date you want to test.
- In the second argument, enter the values you want to get if the date is before you specified.
- Next, in the third argument, enter the values you want to get if the date is after the date you specified.
- In the end, close the function and hit enter to get the result.
Below is the formula which you have written:
=IF(A2>$C$1,"Before","After")
Check If a Date is Before a Date
You can also write a formula where you test for a date if that date is before today’s date or not. For this, you need to write the formula in the following way:
=IF(A2>TODAY(),"Before","After")
In this formula, you need to use the TODAY function to get the date to check the test. As the TODAY function returns the current date, you can test it with the current date to check if it’s before it.
Important: TODAY is a volatile function; it changes value every time you update your worksheet.
To deal with this, you can use the today function in a cell to get the current date and then convert it into value. Or you can manually enter the current date in a cell.