Difference between dates using IF and TODAY...stuck!

Related1

New Member
Joined
May 22, 2017
Messages
21
Hi!

I have two columns. If there is a date in the first column, and no date in the second column I would like the second column to be today's date and then continue with my formula to determine the number of days between the two dates.
2021-12-08_12-00-13.jpg


=networkdays(E14, F14,Holidays!$A$2:$A$15).

If there is no date in the first column, a blank can be returned.

Honestly, I was impressed with myself that I figured out the second part which works when there are dates but I always have a hard time connecting/nesting functions.

Thanks for any help!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Sufiyan97

Well-known Member
Joined
Apr 12, 2019
Messages
1,424
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Try
Excel Formula:
=IF(E14="","",IF(F14="",TODAY()-NETWORKDAYS(E14,F14,$A$2:$A$15),NETWORKDAYS(E14,F14,$A$2:$A$15)))
 
Upvote 0

Related1

New Member
Joined
May 22, 2017
Messages
21
Hi! Thanks for the help. When you see it written out it makes so much more sense.

I used =IF(E52="","",IF(F52="",TODAY()-NETWORKDAYS(E52,F52,Holidays!$A$2:$A$15),NETWORKDAYS(E52,F52,Holidays!$A$2:$A$15))) based off of your suggestion and I received this?

2021-12-08_12-28-03.jpg


But I copied it directly and added 'Holidays' which is the name of the sheet that contains A2:A15.

The cells in column G are formatted as follows:

2021-12-08_12-30-20.jpg

My assumption is that I did something wrong!
 
Upvote 0

Sufiyan97

Well-known Member
Joined
Apr 12, 2019
Messages
1,424
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Try

Excel Formula:
=IF(E52="","",NETWORKDAYS(E52,IF(F52="",TODAY(),F52),Holidays!$A$2:$A$15))
 
Upvote 0
Solution

Related1

New Member
Joined
May 22, 2017
Messages
21
ADVERTISEMENT
YES!!!! Do you mind explaining how this worked and why the other one didn't? I'd like to learn.

THANK YOU.
 
Upvote 0

Sufiyan97

Well-known Member
Joined
Apr 12, 2019
Messages
1,424
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
YES!!!! Do you mind explaining how this worked and why the other one didn't? I'd like to learn.

THANK YOU.
Sure

I made a mistake in previous formula
Below part of formula is totally wrong because in F52 is blank then it will deduct TODAY from start date

=IF(E52="","",IF(F52="",TODAY()-NETWORKDAYS(E52,F52,$A$2:$A$15),NETWORKDAYS(E52,F52,$A$2:$A$15)))

and because we already deduct F52 (end date) here =NETWORKDAYS(E52,F52,$A$2:$A$15)

It gives -31769 and if we deduct it from TODAY's date which is 44539 in (General Format)
It gives 76308

If you put below formula only and deduct it from today's date then you will get an idea that what happens

=NETWORKDAYS(E52,F52,$A$2:$A$15)

Hope this helps!
 
Upvote 0

Related1

New Member
Joined
May 22, 2017
Messages
21
ADVERTISEMENT
Yes, it totally helps and makes sense. I like following the logic on how you discovered the mistake!

Thanks again!
 
Upvote 0

Sufiyan97

Well-known Member
Joined
Apr 12, 2019
Messages
1,424
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
You're Welcome!
Glad I was able to help!
 
Upvote 0

Related1

New Member
Joined
May 22, 2017
Messages
21
2021-12-09_9-09-33.jpg


I have one more request :)

How would I also add an IF where if there are two dates there - I do NOT need the calculation? (It's calculated in another column).
Formula used =IF(E12="","",NETWORKDAYS(E12,IF(F12="",TODAY(),F12),Holidays!$A$2:$A$15))

So if there are two dates in E12 and F12, return " ".

Is this possible?

Thanks.
 
Upvote 0

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
85,161
Office Version
  1. 365
Platform
  1. Windows
How about
Excel Formula:
=IF(AND(E12<>"",F12<>""),"",IF(E12="","",NETWORKDAYS(E12,IF(F12="",TODAY(),F12),Holidays!$A$2:$A$15)))
 
Upvote 0

Forum statistics

Threads
1,195,948
Messages
6,012,475
Members
441,701
Latest member
vnkendijs

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
Top