Help with Datedif based on certain conditions...

Leechmil

New Member
Joined
Aug 21, 2007
Messages
6
Sorry for being a total noob but I'm trying to do something and it's totally
throwing me!

Basically I want to take a date contained in cell H4 and compare it to todays date,

then work out the difference between the two in days, this is working ok using the

datedif function...

=DATEDIF(H4,TODAY(),"d")

However if cell H4 is blank or the date contained in H4 is above todays date it displays #NUM! - is there anyway to hide this?

Thanks in advance for any help!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Steve, thanks for your super-fast reply, much appreciated! that formula worked perfectly but now I presented with another minor problem!

Basically if the cell H9 mentioned previously contains no date then the output cell automatically displays 39315 days!
 
Upvote 0
=if(iserror(DATEDIF(H4,TODAY(),"d")),"Something Wrong",if(h4>0,DATEDIF(H4,TODAY(),"d"),"Date Missing") )
 
Upvote 0
Sorry for being a total noob but I'm trying to do something and it's totally
throwing me!

Basically I want to take a date contained in cell H4 and compare it to todays date,

then work out the difference between the two in days, this is working ok using the

datedif function...

=DATEDIF(H4,TODAY(),"d")

However if cell H4 is blank or the date contained in H4 is above todays date it displays #NUM! - is there anyway to hide this?

Thanks in advance for any help!

=IF(H4,DATEDIF(H4,TODAY(),"d"),"")
 
Upvote 0

Forum statistics

Threads
1,214,620
Messages
6,120,559
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top