Make a negative number to a zero using DATEIF function

EmmaTM

Board Regular
Joined
Jan 5, 2022
Messages
74
Office Version
  1. 365
Platform
  1. Windows
Hi,
I want to take the number of days between 2 dates however when this is a negative number I want that to result in a zero.
The figures in cells L13 & L14 were both negative but I want these to be zero.
The formula I have used is:
=DATEDIF(IF(E13<$M$1,E13,$M$1+1),IF(E13>$M$1,E13,$M$1+1),"d")

1641396804669.png


Thank you
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
See cell L9 above which is showing 104 days, this should be 92 days.
I am trying to work out the number of days from the start date to the month end date so in this case its 19/8/21 to 30/11/21 which should be 92 days.
 
Upvote 0
But your formula calculates date based on cell M1 which is 30/11/2021
So you need to change the reference

Book2
DEFGHIJKLMN
111/30/2021
2
3
4
5
6
7
8
98/19/202111/18/202110491
10
11
Sheet1
Cell Formulas
RangeFormula
I9I9=DATEDIF(IF(E9<$M$1,E9,$M$1+1),IF(E9>$M$1,E9,$M$1+1),"d")
J9J9=F9-E9
 
Upvote 0
August 18th through November 30 is 104 days. 14 in August, 30 in September, 31 in October, 30 in November. 14+30+31+30 = 105. This is 1 higher than 104 since it counts both endpoints.
 
Upvote 0
Is there a formula I can use that would look at the end date and look at the month end date and tell me the number of days. For example if the month end date is 30/11/21 and then:
I have an end date of 18/11/21 I would want this to show 18 days in Nov.
I have an end date of 15/12/21 I would want this to show 30 days in Nov.

Thank you
 
Upvote 0

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

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