DATEDIF To show negative

LilPeteMordino

New Member
Joined
Jan 23, 2025
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Apologies. I have had a quick look but can't really find anything that I can utilise.

I have a relatively simple formula that takes an estimated completion date against a required completion date and gives me the number of months between the two. All happy days, however if the estimate goes past the required, it is showing a negative. How can I fix this please?

Excel Formula:
=IFERROR((DATEDIF(H14,G14,"m")), "")

So H14 is Estimated, G14 is Required.

Unless I have this all wrong!

Cheers in advance.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Assuming you meant "however if the estimate goes past the required, it is showing an error....

Test if H14>G14, if it is then reverse the formula and multiply by minus 1 (I've left the IFERROR in but I doubt you'll need it)

Book1
GHIJ
1401/06/202401/04/20242
1501/04/202401/06/2024-2
Sheet1
Cell Formulas
RangeFormula
J14:J15J14=IFERROR(IF(H14>G14,DATEDIF(G14,H14,"m")*-1,DATEDIF(H14,G14,"m")),"")
 
Last edited:
Upvote 0
Test if H14>G14, if it is then reverse the formula and multiply by minus 1 (I've left the IFERROR in but I doubt you'll need it)

Book1
GHIJ
1401/06/202401/04/20242
1501/04/202401/06/2024-2
Sheet1
Cell Formulas
RangeFormula
J14:J15J14=IFERROR(IF(H14>G14,DATEDIF(G14,H14,"m")*-1,DATEDIF(H14,G14,"m")),"")
That's worked perfectly! Thank you. I didn't even think about incorporating an IF to consider the arrangement first.

The IFERROR is included because I have 'pre-populated' a table with the next two years worth of calculations (Its a sheet that pulls monthly data in and shows the trends). So it just keeps the sheet looking tidy.
 
Upvote 0

Forum statistics

Threads
1,226,074
Messages
6,188,729
Members
453,495
Latest member
Pippie4trnc

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