# Conditional formatting based on dates

Copper Contributor

# Conditional formatting based on dates

If I have a ‘received date’ in column B and a ‘completed date’ in Column D and want column E to turn green if the completed date was within 7 days and red if over 7 days, what formula do I use?  Thank you.

3 Replies

# Re: Conditional formatting based on dates

1. Select the cells in col E
2. Choose Conditional format, New Rule
3. Select "Use formula to determine..."
4. Enter this formula (assuming your data starts on row 2):
=D2-C2<=7
5. Click Format and set a green fill.

Do these same steps for over 7 days, change the formula to D2-C2>7 and set a red fill

# Re: Conditional formatting based on dates

@Jan Karel Pieterse thank you so much, I will give it a try.
I also have a colum calculating the number of days between received and completed, do you know if there’s a formula I can use to calculate the overall percentage that are within the 7 days?  Thank you again.

# Re: Conditional formatting based on dates

Let's say the number of days can be found in G2:G50.

Enter the following formula in a cell  and format it as a percentage:

=COUNTIF(G2:G50, "<=7")/COUNT(G2:G50)