DATEDIF when two dates are the same

Imran Azam

Board Regular
Joined
Mar 15, 2011
Messages
103
Hi

I have this formula which i am using to find the number of days difference between from two dates

DATEDIF(F5,P5,"D")

when the two dates are the same it is coming back with 0, how do i change this formula so when the dates are the same it brings back 1?

Thank you
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
0 is a proper result
but if you really want you can IF(F5=P5,DATEDIF(F5,P5,"D")+1,DATEDIF(F5,P5,"D"))
 
Last edited:
Upvote 0
Hey, try:

=IF(DATEDIF(F5,P5,"D")=0,1,DATEDIF(F5,P5,"D"))
 
Upvote 0
refresh thread

or

IF(F5=P5,1,DATEDIF(F5,P5,"D"))
 
Last edited:
Upvote 0
=MAX(1, DATEDIF(F5,P5,"d"))
or
=MAX(1, P5-F5)

As the latter demonstrates, usually there is no need to use DATEDIF(...,"d") if F5 and P5 contain dates only (no time component).
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,016
Members
448,543
Latest member
MartinLarkin

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