+ Reply to Thread
Results 1 to 32 of 32

Formula calculates correct time difference but not calculating >12 hrs means late

  1. #1
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Formula calculates correct time difference but not calculating >12 hrs means late

    I have this formula that is calculating the time difference between two dates and time. Now just some clarification I have in cells of the two different dates and times that say NULL that is supposed to be. But i realized that my formula was calculating correctly except it wasn't bringing into account that if the difference between the two dates and times was greater than 12 hour that meant it was late.
    Here is my formula that is used my sample excel
    =IF(SIGN(D4-I4)<0,"LATE ","")&INT(ABS(D4-I4))&" days, "&HOUR(ABS(D4-I4))&" hours, "&MINUTE(ABS(D4-I4))&" minutes and "&SECOND(ABS(D4-I4))&" seconds"

    I am also attaching a sample excel so you can see how the formula is calculating.
    Attached Files Attached Files

  2. #2
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Pls use code tags whe posting formulas.

    The dates and times you doing the calculations with are formated as text. That gives a #VALUE error.
    Change the formula in D4 to
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Change the formula in I4 to
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Then you can change the formula in E4 to
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  3. #3
    Registered User
    Join Date
    07-11-2017
    Location
    USA
    MS-Off Ver
    2013
    Posts
    11

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Hello,

    I'm not proficient in Excel, but I've done time formulas in the past. Would the below work for you?

    Please Login or Register  to view this content.

    May also need to work in an IF statement to account for 24 hours/day so the AM-PM doesn't throw it off.
    Last edited by DreamVista; 07-19-2017 at 10:39 AM.

  4. #4
    Registered User
    Join Date
    07-11-2017
    Location
    USA
    MS-Off Ver
    2013
    Posts
    11

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    I believe that Tsjallie incorporated the IF statement, looks like a great solution!

  5. #5
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    @Tsjallie I know that the first two cells in column E have #VALUE! errors that is supposed to be that way. I need column E to determine based on columns D and I and calculated in E if it is late in Column J. When I implemented your formulas to columns D, I and E it removed the LATE before the days, etc in Column E but didnt change Column J.

  6. #6
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    In the formula in column E your doing a calculation with textvalues (columns D & E). That's not gonna work.
    Unless I isinterpreted your requirement I believe that the word "LATE" should only appear when the difference between the D and E is more than 12 hours.
    In row 4 that difference is less. When you change the date in cell F to 1 day later the word "LATE" will appear.

  7. #7
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    I need help creating a formula that calculates time difference between two different dates and times. Sometimes the dates can be the same but the times can be different. In addition in a another column I need to calculate whether based on this formula the time difference is considered late or on time. This all based on the fact that any calculation of the time difference that is under 12 hrs is considered on time. I have a sample excel sheet that shows what I am trying to do with a formula for both but I dont believe that the formula for time difference is considering the less than 12 = on time rule.

    PLEASE NEED ANY HELP BEEN STUCK ON THIS FOR A COUPLE WEEKS NOW!!!!!
    Any help is super appreciated.

  8. #8
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    the solutions above were not working.

  9. #9
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    still using the same sample from above

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    One example will probably NOT be enough to give you an answer. However...

    D2: =A2+IF(B2="NULL",0,B2) formatted as date/time

    I2: =F2+H2 formatted as date/time

    J2: =IF(I2-D2>0.5,"Late","OnTime")

    I JUST TRIED POSTING ON YOUR DUPLICATE THREAD. I have not read any of the posts earlier on this thread.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  11. #11
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    here i will attach a more updated sample

  12. #12
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    here is the updated excel
    Attached Files Attached Files

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    1. It's the same sheet.

    2. How did my attempt work out?

  14. #14
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    sorry here is an updated one with an example with dates and times for both.
    Attached Files Attached Files

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    See the attached file. there are too many changes to spell them out line-by-line here. Happy to explain any of them.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Just to clarify that the excel you sent me considers that even if the time difference is less than 12 hrs its considered on time?

  17. #17
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    I must have attachef the wrong sheet, too !!!

  18. #18
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Ignore this post.

  19. #19
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    No. I'm confused. At what point does it become late. What criteria do you want to use?

  20. #20
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    it becomes late when the time difference is greater than 12 hours

  21. #21
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    So... what's wrong with the outcome at J2 and J4 of the sheet I posted back at # 15?????

  22. #22
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    it works the only thing i was wondering could we have the times include the seconds.

  23. #23
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Yes - just adjust the formatting to include seconds tso times become hh:mm:ss instead of hh:mm

    and similarly for date times.


    However, when your benchmark is 12 HOURS, the relevance of the seconds and even the minutes is very, very questionnable.
    Attached Files Attached Files

  24. #24
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,039

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    E2: I2-D2 (no need so complicated formulas)
    Then, format the cell as: d "days" h "hours" m "minutes" s "seconds"

  25. #25
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Josephtey - valid point. I didn't even look at that cell!! have some Rep.

  26. #26
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Im still having the issue with converting my dates to your formula Glenn Kennedy. I am attaching the file with the issue. it just the first row of the sheet because it was giving me a weird number.
    Attached Files Attached Files

  27. #27
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    The formula in E1 was pointing to column I (time) not column J (date time).

    =IF(SIGN(D1-J1)<0,"LATE ","")&INT(ABS(D1-J1))&" days, "&HOUR(ABS(D1-J1))&" hours, "&MINUTE(ABS(D1-J1))&" minutes and "&SECOND(ABS(D1-J1))&" seconds"

  28. #28
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    yes thank you but now I noticed that the determination for it to be on time or late isnt work there is an extra column that basically makes a 0 on time and 1 late but its showing most are on time despite being over 12 hours for obviously some lines.
    Attached Files Attached Files

  29. #29
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Same issue. You have messed up the formula in column L. It was referring to column I when it should have been referring to column J.
    Attached Files Attached Files

  30. #30
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,039

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Quote Originally Posted by Glenn Kennedy View Post
    Josephtey - valid point. I didn't even look at that cell!! have some Rep.
    Thanks Glenn!

  31. #31
    Registered User
    Join Date
    07-17-2017
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    56

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Thank You so much for all the help

  32. #32
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Formula calculates correct time difference but not calculating >12 hrs means late

    Glad we got there in the end. so, of course...

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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: 6
    Last Post: 05-20-2023, 01:07 AM
  2. [SOLVED] Problem with creating a correct formula for calculating STDEV for several time series.
    By Exceltrouble in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-14-2016, 09:43 AM
  3. Time difference calculating formula needed
    By nahidking in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-03-2015, 06:17 AM
  4. [SOLVED] Formula for calculating time difference between two cells
    By mprasanna in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-05-2015, 04:54 AM
  5. [SOLVED] Calculating time difference between two days combined with IF formula
    By kj2607 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-30-2014, 06:20 AM
  6. Replies: 5
    Last Post: 07-20-2012, 12:42 PM
  7. Can't get the difference in time correct
    By Lewis Koh in forum Excel General
    Replies: 5
    Last Post: 04-20-2010, 08:39 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