Comparing Dates

M

mlv

I need to check to see if the dates in two discrete cells are the same.
However, I only want to compare the month and the year, the day doesn't
matter.

For example:

A1 12/04/2007

B1 30/04/2007

C1 12/05/2007

D1 12/04/2006

IF(A1=B1,"TRUE","FALSE") result TRUE (the month and the year are
identical).

IF(A1=C1,"TRUE","FALSE") result FALSE (the months are different).

IF(A1=D1,"TRUE","FALSE") result FALSE (the years are different).

Is this easy to achieve?

Thanks
 
P

Pete_UK

Use MONTH and YEAR, as follows:

=IF(AND(MONTH(A1)=MONTH(B1),YEAR(A1)=YEAR(B1)),TRUE,FALSE)

or even just:

=AND(MONTH(A1)=MONTH(B1),YEAR(A1)=YEAR(B1))

Hope this helps.

Pete
 
H

Harlan Grove

Pete_UK said:
Use MONTH and YEAR, as follows:

=IF(AND(MONTH(A1)=MONTH(B1),YEAR(A1)=YEAR(B1)),TRUE,FALSE)

or even just:

=AND(MONTH(A1)=MONTH(B1),YEAR(A1)=YEAR(B1))
....

Or just use DAY.

=(A1-DAY(A1)=B1-DAY(B1))
 
D

Dana DeLouis

Maybe another option. This function is missing in my Help files of 2007,
but I think this is correct.

=DATEDIF(A1,B1,"m")=0
 
M

mlv

Dana said:
Maybe another option. This function is missing in my Help
files of 2007, but I think this is correct.

=DATEDIF(A1,B1,"m")=0

Hi Dana

Unfortunately this formula seems to fail if the date in Cell B1 is earlier
than the date in Cell A1 (which in my application, it might well be). The
result is a number error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top