IF statement with DATEDIF

smazza

New Member
Joined
Feb 11, 2011
Messages
18
I'm trying to write a formula & it keeps saying that my formula is incorrect. I want to say if there is a value in cell A1, then calculate the months between A1 & B2, otherwise, leave blank. Here is what I have been writing that keeps coming back incorrect.

=IF(A1>0,(=DATEDIF(A1,A2,"m")),"")

I have changed the A1>1/1/1900 & that isn't the issue. It's the DATEDIF statement because when if use the fx button, that's the only part that come up "Illogical."
<!-- / message -->
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

T. Valko

Well-known Member
Joined
May 9, 2009
Messages
16,623
I'm trying to write a formula & it keeps saying that my formula is incorrect. I want to say if there is a value in cell A1, then calculate the months between A1 & B2, otherwise, leave blank. Here is what I have been writing that keeps coming back incorrect.

=IF(A1>0,(=DATEDIF(A1,A2,"m")),"")

I have changed the A1>1/1/1900 & that isn't the issue. It's the DATEDIF statement because when if use the fx button, that's the only part that come up "Illogical."
<!-- / message -->
Try something like this...

=IF(COUNT(A1,A2)<2,"",DATEDIF(A1,A2,"m"))
 

Watch MrExcel Video

Forum statistics

Threads
1,109,518
Messages
5,529,311
Members
409,862
Latest member
lbisacca
Top