+ Reply to Thread
Results 1 to 22 of 22

Hi, issue with days between dates

  1. #1
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Hi, issue with days between dates

    Hello there,

    It seems I am getting a weird change in days when using the following:

    Explanation.xlsx

    What it basically comes to, I have 3 dates, whereby I calculate the ''=networkdays'' (I assume those are working days minus Saturday/Sunday) I am getting an extra day with the first line of dates.

    *What I have thought about myself: perhaps due to the fact that the dates include data which is in a weekend (19-10-2014) this could possibly mean an error? the weird thing however is that the second line of dates also include one date in a weekend (14-10-2014)

    Could someone please help me, much appreciated!

    -Sabrina

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Hi, issue with days between dates

    The formulas in your posted workbook are returning corrct values.
    To verify...
    • List the dates from 13-Oct through 14-Nov.
    • Format those dates to see the date and day (Example: Monday, October 13, 2014)
    • Then check the calculations.

    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Hi, issue with days between dates

    NetWorkDays always includes the first day as 1 (provided it's a workday)
    so NetWorkDays(11/21/2014, 11/21/2014) = 1
    NetWORKDAYS(11/20/2014, 11/21/2014) = 2 even though there's 1 day difference. If you don't want to start counting from the first date, subtract 1
    =NETWORKDAYS(11/20/2014, 11/21/2014)-1

    Any weekend days count as 0 so
    =NETWORKDAYS(11/22/2014 (Saturday), 11/23/2014 (Sunday)) = 0
    Did that help?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    Thank you so much for your replies both Ron and chemist!

    I'm trying to make sense out of it, however, Chemist, what would be the correct formula for both these lines of dates if I only want to know the difference between them (excluding the weekends)

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Hi, issue with days between dates

    For example, E6 would be

    =NETWORKDAYS(B6,D6)-1
    If you use that formula throughout, do you have any that do not give you what you would expect?

  6. #6
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    Yes, that fixes the first one, but I cannot do that for the second one (changes the dates)

    I am looking for a sustainable formula which will work on let's say, 3000/4000 dates, which includes both the situation with the first and second date.

    Would there be such thing?

    Thank you so much for your help!

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Hi, issue with days between dates

    I'm not following. In which column could you not do that?

  8. #8
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    Sorry, trying to do my best to get my head around this.

    I actually does not fix anything, I will try to be a little more clear:

    Order + POD = 24
    ------------------------
    Tracking + POD = 5
    Order + tracking = 20
    _____
    25 <-- this should be 24, not 25. Because remember, Order + POD = 24, it cannot be that the steps in between are able to add one day, which is currently happening.

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Hi, issue with days between dates

    If you correct all your NETWORKDAY Formulas to be the same then the sums will work out. See attachment.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    Thanks once again, that is also what I tried.

    However, when looking order: 13/10/2014 and 19/10/14 - that is clearly 5 working days, your formula makes that 4, which is not correct.

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Hi, issue with days between dates

    Ahhh, lightbulb

    Okay, the problem with F+G =E is that there is a day that is counted twice, the day of tracking. So you need to subtract 1 from that formula.
    In your second row, the tracking day is a Sunday so it counted as 0 and 2 * 0 still equals 0 so that row works.
    Will your tracking day sometimes appear on non-work days? If so, we can work out a formula that takes that into account. I assume Order days are always on workdays, how about POD days?

  12. #12
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    Awesome!

    Well actually, all the 3 dates in each line, can occur in the weekend. Both an order can made in the weekend, Tracking van be updated in the weekend, and POD's can be signed in the weekend.

    I can try to upload the whole file I am working on, just dont see it so quickly where to do that.

    Help is much appreciated!!

  13. #13
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    testt.xlsx

    Ok it worked, as you can see, most of my lines of date (about 99% even) have in column J a -1, which means that the time from customer order, till POD signed by customer is (for example) 25, but should be -1 to reflect 24 (which is correct) <-- sorry for being so confusing, hope it makes sense!

  14. #14
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Hi, issue with days between dates

    Okay, In G, I put this formula

    =IF(WEEKDAY(B2,2)>5, D2+E2, D2+E2-1)

    It seems to work from the ones I checked. In your file, I also substituted NETWORKDAYS into D and E. Towards the end you have some where the tracking date comes after the POD date which doesn't make sense to me so not sure how that would be calculated.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    Sorry, I had to go for a moment. Will test just now and let you know. Thank you so much!

  16. #16
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    Thanks Chemist,

    Maybe I forgot to say that I am OK with the point of order to POD, those with a simple =networkdays is working, however between those two dates, between the date of order and POD, I have two additional steps.

    1. From the order till tracking is added to the order
    2. Tracking placed to the order, order is delivered (POD)

    Currently, when point of order till POD is 9 days, point 1 + point 2 will be 10 days, which is wrong, it also should be 9 days.

    I am wondering, why is this not also 9 days, where is the extra day coming from?

  17. #17
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    1. Order, till order receives tracking
    2. Tracking till delivery (POD)

    If from Order to POD = 10 days, If I apply point 1 + 2 I will always get 11 days, where is that extra day coming from, that is my main concern, can you help me with that?

  18. #18
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Hi, issue with days between dates

    Can you point to an example on your sheet or upload a new sheet with some examples?

  19. #19
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    test2.xlsx

    See my info in Green / Column P

    Thanks!

  20. #20
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Hi, issue with days between dates

    It's not a case of which column has the extra day, it's that you are adding 1 day twice.

    Simple case, Order is done on Monday, Tracking on Wednesday, POD on Friday

    From Order to Tracking = Mon, Tues, Wed = 3
    From Tracking to POD = Wed, Thur, Fri = 3
    From Order to POD = Mon, Tue, Wed, Thur, Fri = 5

    That's why my formula subtracts 1 if the tracking occurs on a weekday
    =IF(WEEKDAY(B2,2)>5, D2+E2, D2+E2-1)
    Does that help or am I missing the point again?

  21. #21
    Registered User
    Join Date
    12-14-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Hi, issue with days between dates

    From Order to Tracking = Mon, Tues, Wed = 3
    From Tracking to POD = Wed, Thur, Fri = 3
    From Order to POD = Mon, Tue, Wed, Thur, Fri = 5

    That exactly, that is where I would use Wed x2

    But if I use your formula, it changes the ''From Order to POD'', and takes away one day there.

    What I need to know, or what is more important are:

    From Order to Tracking = Mon, Tues, Wed = 3
    From Tracking to POD = Wed, Thur, Fri = 3

    Because that somehow should be 5 as well, it cannot be that from order to delivery = 6 days, while in real its 5 days, I'm sure you understand this even better than I do, and that is why it's so difficult for me to explain this

    is it somehow possible to eliminate that extra day in:

    From Order to Tracking = Mon, Tues, Wed = 3
    From Tracking to POD = Wed, Thur, Fri = 3

    or should I just take 0.5 days off each?

  22. #22
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Hi, issue with days between dates

    I still think the best way to handle this is, in the cell where you are doing the adding, (Column P in test2)


    =IF(WEEKDAY(B5,2)>5, M5+N5, M5+N5-1)

    Or you could just accept that Excel knows what it is doing and that the formula for Networkdays for Order to POD is correct

    =NETWORKDAYS(A5,C5)
    Last edited by ChemistB; 11-20-2014 at 10:04 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 10-31-2014, 10:32 AM
  2. Replies: 2
    Last Post: 02-20-2014, 06:40 AM
  3. [SOLVED] Number of Days Between Dates but if no Date go to next and return # of Days
    By Bikeman in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-14-2012, 12:02 PM
  4. Replies: 1
    Last Post: 11-01-2012, 03:41 PM
  5. [SOLVED] Subtract Two Dates By The Number of Days, But Only Inlcude Work Days
    By ptho16 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-16-2012, 11:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1