+ Reply to Thread
Results 1 to 10 of 10

Formula for finding last delivery date and time

  1. #1
    Registered User
    Join Date
    02-26-2008
    MS-Off Ver
    Excel 2016
    Posts
    23

    Formula for finding last delivery date and time

    Hello,
    My company receives shipments every Wednesday at 4pm and Saturday at 4pm.
    I have a list of event times in column A and in column B, I would like a formula to list when the the shipment arrives for that row's event.
    In my attached spreadsheet, I've included some examples, with the answer I need in column C

    So for an event on Wednesday, June 12 @ 8am, items were delivered on the past Saturday, June 9 @ 4pm
    But an event later that day, Wednesday, June 12 @ 7pm, the items were delivered only a few hours earlier, Wednesday, June 12 @ 4pm.

    Also a brief explination as to why this works would be helpful for future problems of mine.
    This type of time math always confuses me!
    Thanks in advance for the help! and let me know if I need to explain my problem differently.
    Joe
    Attached Files Attached Files

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula for finding last delivery date and time

    So why is your very first answer Sunday June 3rd, 2012??

  3. #3
    Registered User
    Join Date
    02-26-2008
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Formula for finding last delivery date and time

    Because I am a fool, it should be Saturday June 2.

    Sorry about that!!

  4. #4
    Registered User
    Join Date
    02-26-2008
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Formula for finding last delivery date and time

    Because I am a fool, it should be Saturday June 2.

    Sorry about that!!

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula for finding last delivery date and time

    Try this - I haven't fully tested it.

    =IF(AND(OR(WEEKDAY(A2)={4,6}),HOUR(A2)<16),INT(A2),INT(A2)-CHOOSE(WEEKDAY(A2),1,2,3,4,1,2,3))+16/24

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula for finding last delivery date and time

    Switch that < sign to > sign.
    And change the {4,6} to {4,7}.

    All results match your expected results (after changing the Jun 3 to Jun 2).

    I'll provide the explanation once you verify it works the way you want it to.
    Last edited by Cutter; 06-14-2012 at 03:57 PM.

  7. #7
    Registered User
    Join Date
    02-26-2008
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Formula for finding last delivery date and time

    Cutter, it works for everything I throw at it!

    So why does it work? I need to do these types of calculations all the time and as you saw from my uploaded file, I'm helpless without it.
    Last edited by joedrummer; 06-14-2012 at 04:40 PM.

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula for finding last delivery date and time

    Good stuff. Glad to hear it works for you. Now the explanation:
    =IF(AND(OR(WEEKDAY(A2)={4,7}),HOUR(A2)>16),INT(A2),INT(A2)-CHOOSE(WEEKDAY(A2),1,2,3,4,1,2,3))+16/24

    The first part: IF(AND(OR(WEEKDAY(A2)={4,7}),HOUR(A2)>16) says this
    If the date in A2 is a Wednesday or Saturday ({4,7}) and the time is after 4pm (HOUR()>16) then ....
    If that part is true the result for that condition is the date (without the time) shown in A2
    If the first part is false then a variable # will be subtracted from the date in A2. That variable # is determined by the CHOOSE() function and is dependent upon the WEEKDAY() value of A2 - Sunday is 1, Monday is 2, Tuesday is 3......
    For example if A2 is a Tuesday you want to backtrack 3 days to get to Saturday - you'll see that the 3rd option within the CHOOSE() is a 3.
    So the IF() function determines the delivery date and then 4pm is added to it (the 16/24 part - 16 being the 16th hour of 24 hour day)
    The end result is Date + 4pm

  9. #9
    Registered User
    Join Date
    02-26-2008
    MS-Off Ver
    Excel 2016
    Posts
    23

    Re: Formula for finding last delivery date and time

    Thank you cutter!

  10. #10
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formula for finding last delivery date and time

    You're welcome. Clear as mud????

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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