Help with Date calculations

S

SafetyIntern

I have tried two different ways to do this; I have a cell (O1) that has
=Today() to show current date, I also have a cell (K23) that has the date of
a certificate. I want to subtract the two dates to know how many months are
between the two. Once this number hits over 12 I have conditional formatting
set up to change the shading and font color.

Here is my problem, when i entered in either of the formulas I tried I got a
result of 1303, and there was NOT a date in the cell K23. It will give a
value even though there is nothing to subtract from.

The formula I tried is
=(year(O1)-year(k23))*12+month(O1)-Month(k23)

I have this in another spreadsheet and works perfectly and if there is no
dateis entered, there is no answer given.

Can someone help me????
 
B

Bob Phillips

You are getting 108 years

=IF(K23="","",(year(O1)-year(k23))*12+month(O1)-Month(k23))
 
M

Mike H

Hi,

Try this to get the difference in months.

=IF(K23="","",DATEDIF(K23,O1,"m"))

Mike
 
S

SafetyIntern

Thank you so much for your help!!!!!!!!! I will be able to keep a little of
my hair, that I've been pulling out trying to figure out where I messed up
 
D

daddylonglegs

To get exactly the same result with DATEDIF

=IF(K23="","",DATEDIF(K23-DAY(K23)+1,O1,"m"))
 

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