Comparing Dates

  • Thread starter Thread starter mlv
  • Start date Start date
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
 
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
 
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))
 
Maybe another option. This function is missing in my Help files of 2007,
but I think this is correct.

=DATEDIF(A1,B1,"m")=0
 
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.
 
Back
Top