# Microsoft Office Application Help - Excel Help forum > Excel Formulas & Functions >  > [SOLVED] Using IF function to compare dates of two cells

## Mr.WalterJones

Hi Everyone. I did a little searching through the board and could not find this post anywhere else. If it is a re-post I apologize in advance.

I am trying to compare two different dates of two different cells (for example cell A1 is 7/9/2012 and cell B2 is 5/6/2012). I would like to write an IF function that states if the date in A1 is the same as or earlier than the date in B2 than display "YES" and if not than display "NO". Is this possible? This question may be a bit convoluted and missing the right terminology as I am an Excel noob. Thanks for the help!

----------


## tigeravatar

Mr.WalterJones,

Welcome to the forum!
Give this a try:
=IF(A1>B2,"NO","YES")

----------


## Mr.WalterJones

EDIT:

NEVERMIND! That worked. I guess I had a typo or something. Thank you. 

I have another question. Can you automatically add weeks to a cell? For example for every cell in column C I want to add 4 weeks to that date and put that value in column D. Example: C2 says 5/12/2012 and I want D2 to display 6/9/2012.

----------


## tigeravatar

Each day in excel is a whole number.  So 4 weeks is 28 days, making the formula:
=C2+28

----------

