+ Reply to Thread
Results 1 to 10 of 10

Formula for time difference

  1. #1
    Registered User
    Join Date
    08-05-2019
    Location
    New Delhi
    MS-Off Ver
    2013 and Office 365
    Posts
    14

    Formula for time difference

    I am trying to create an excel file where i put in the name of the person, location and there shift time (Start and End columns). I want to convert this shift time into EST or EDT as per the location.
    1. The person can be located anywhere in the world.
    2. The shift timing can vary from person to person.

    The formula i have used does convert the time but where i get stuck is when the time is for the day before. The system shows an error.

    Capture.PNG

    Any help would be appreciated.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,015

    Re: Formula for time difference

    You have posted in the VBA section - shall I move the thread for you?

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    08-05-2019
    Location
    New Delhi
    MS-Off Ver
    2013 and Office 365
    Posts
    14

    Re: Formula for time difference

    Just to add on the formula i am using is as follows.

    =IF($B$1="Yes",D4-VLOOKUP($C4,Sheet2!$B:$D,2,0),D4-VLOOKUP($C4,Sheet2!$B:$D,3,0))

    The Sheet 2 has the table as follows:

    Attachment 772906

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,015

    Re: Formula for time difference

    So shall I move the thread? Please provide a sample workbook. Thanks.

  5. #5
    Registered User
    Join Date
    08-05-2019
    Location
    New Delhi
    MS-Off Ver
    2013 and Office 365
    Posts
    14

    Re: Formula for time difference

    Yes pls move it to the correct board

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,015

    Re: Formula for time difference

    OK - will do. Waiting for you to attach a workbook.

  7. #7
    Registered User
    Join Date
    08-05-2019
    Location
    New Delhi
    MS-Off Ver
    2013 and Office 365
    Posts
    14

    Re: Formula for time difference

    I have attached a sample file
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,003

    Re: Formula for time difference

    Try the following:
    For column F:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    For column G:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    Attached Files Attached Files
    Last edited by JeteMc; 03-22-2022 at 11:10 AM. Reason: Added file
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  9. #9
    Registered User
    Join Date
    08-05-2019
    Location
    New Delhi
    MS-Off Ver
    2013 and Office 365
    Posts
    14

    Red face Re: Formula for time difference

    Quote Originally Posted by JeteMc View Post
    Try the following:
    For column F:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    For column G:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.
    This worked great for me. Thank you for the help.

    Could you provide me with the explanation of what it is doing? I am not able to put my finger on the logic here.
    Last edited by amitesh9; 03-23-2022 at 09:27 AM.

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,003

    Re: Formula for time difference

    The formula in column F takes the corresponding time value in column D and adds 1 if the VLOOKUP($C4,Sheet2!$B:$D,2,0)>D4 portion returns True (value found on Sheet2 is greater than the value in column D).
    If the VLOOKUP($C4,Sheet2!$B:$D,2,0)>D4 portion returns false then zero is added.
    The formula then subtracts the VLOOKUP($C4,Sheet2!$B:$D,2,0) value to give the final time value.
    A good way to see this at work would be to select cell F7, which previously returned an error, and utilize the Evaluate Formula feature on the Formulas tab.
    Let us know if you have any questions.

+ 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: 1
    Last Post: 10-18-2019, 12:38 AM
  2. Replies: 3
    Last Post: 08-12-2017, 01:48 AM
  3. Formula Help for Time Difference
    By AvidanR in forum Excel General
    Replies: 1
    Last Post: 07-27-2017, 09:48 AM
  4. Difference between Time formula
    By ClintonL in forum Excel General
    Replies: 7
    Last Post: 02-21-2017, 01:37 AM
  5. Averaging Time after using formula to determine time difference
    By Yfandeslady in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-26-2014, 03:22 PM
  6. [SOLVED] Formula for time difference
    By MyOnion in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-19-2013, 03:13 AM
  7. Time Difference Formula
    By MEL79 in forum Excel General
    Replies: 2
    Last Post: 03-11-2005, 05:57 PM

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