+ Reply to Thread
Results 1 to 8 of 8

I need help calculating time difference and am hoping someone can help me? (Crossposted)

  1. #1
    Registered User
    Join Date
    01-01-2020
    Location
    Montana, USA
    MS-Off Ver
    365
    Posts
    19

    I need help calculating time difference and am hoping someone can help me? (Crossposted)

    I am creating a document that determines if employees are allowed specific meals based on several different times. I have the morning meal and evening meal as I could use a set time for excel to look at, however, for the midday meal, there are actually four times that must be considered. First, excel needs to determine, from the travel times entered by the employee, if the employee was in travel at any time between the hours of 10:01 a.m. and 3:00 p.m.. Then, excel also needs to determine if they were in travel status for at least 3 hours between those times. For example, an employee may put down that they left at 6:30 a.m. and returned at 2:30 pm. So excel needs to determine first, that the employee did in fact travel between the allotted times, and second, that the employee was in travel status for at least 3 hours (3/24) during that time frame. This will then allow me to program my document to give them the meal per diem allowances that they are eligible to receive I do not even know where to start.

    The morning meal was similar in that they had to be in a travel status for at least 3 hours (3/24) before 10:00 a.m. which I was able to set up by using a set time of 10:00 and subtract the time they left, and then determined that they had been in travel status for 3 hours (when they left at 6:30 a.m.). The evening meal was also similar in that they had to be in a travel status for at least 3 hours (3/24) after 3:01 p.m. which I was able to set up by using a set time of 3:01 and subtract that from the time that they returned to determine if they had been in travel status for the 3 hours required (which they weren't as they returned at 3:00 p.m. in the example above).

    So my dilemma then is the midday meal where I need to determine if the employee was in travel status for 3 full hours between 10:01 a.m. and 3:00 p.m. as stated above. Is there a way to tell excel to look at the times between set times and the times traveled to determine if they are eligible for the meal? I am using a userform to setup data entry but these calculations are simply formulas and functions on the spreadsheet where the data is populated from the userform entry. I am not doing these formulas, etc. through vba as I wasn't sure how to code that. If it would be easier in vba and someone can tell me how to do so, I would be thrilled to move it to that method instead as I feel vba works so much smoother and more seamless that the functions and formulas on a document that many people will be using.

    I have attached a copy of the document with business info removed. You will see on the 'Travel Expense Voucher' tab, additional columns to the far right with my formulas and working info. I have tried to figure this out now for several weeks and would appreciate any help that anyone can give. Again, as I said earlier, if I could do this through vba that would be preferred but I don't know that it would work properly as I do not know how to code that piece?

    Thank you so much in advance... I really hope someone can help me.
    Attached Files Attached Files

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

    Re: I need help calculating time difference and am hoping someone can help me? (Crosspost

    Welcome to the forum.

    You are required to tell us WHERE you have cross posted this request, please: which other fora have you used?
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    01-01-2020
    Location
    Montana, USA
    MS-Off Ver
    365
    Posts
    19

    Re: I need help calculating time difference and am hoping someone can help me? (Crosspost

    I'm sorry, the crosspost was on the Chandoo.org forum. There was a very nice gentleman that attempted to help me and I have no doubt that his solution may have worked but it doesn't seem to be working on my document, or maybe I'm too stupid to figure out how to make it happen right? I don't know which, so I was hoping that something a bit easier could be suggested so I can maintain what I create.

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

    Re: I need help calculating time difference and am hoping someone can help me? (Crosspost

    So really, what you should do is tell us the solution that was offered there. This way we know what's already been suggested. It's about limiting duplication of effort - do you see? So what was the solution offered on Chandoo?

  5. #5
    Registered User
    Join Date
    01-01-2020
    Location
    Montana, USA
    MS-Off Ver
    365
    Posts
    19

    Re: I need help calculating time difference and am hoping someone can help me? (Crosspost

    Of course, I have attached what he suggested. As I said, I have no doubt that it would work, but I don't know how to use it nor could I ever hope to support it as I don't understand it well enough.
    Attached Files Attached Files
    Last edited by KristenBCK; 01-07-2020 at 09:42 PM.

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

    Re: I need help calculating time difference and am hoping someone can help me? (Crosspost

    Is this the formula you don't understand?

    = SUMPRODUCT( IF( qualifyingPeriod < travelPeriod, qualifyingPeriod, travelPeriod ), {1,-1;-1,1} )

    Did you ask the person who helped you on Chandoo to explain the solution for you? I cannot find the thread in question.

  7. #7
    Registered User
    Join Date
    01-01-2020
    Location
    Montana, USA
    MS-Off Ver
    365
    Posts
    19

    Re: I need help calculating time difference and am hoping someone can help me? (Crosspost

    I did, and he returned this information.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-01-2020
    Location
    Montana, USA
    MS-Off Ver
    365
    Posts
    19

    Re: I need help calculating time difference and am hoping someone can help me? (Crosspost

    I think I have it figured out. Thank you for listening but I used the information in a link on get-digital-help.com. The title of the page is 'How to count overlapping time'.

+ 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. [SOLVED] Calculating Time Difference
    By Chasermelb in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-03-2019, 06:31 AM
  2. Replies: 3
    Last Post: 08-12-2017, 01:48 AM
  3. Calculating time difference
    By dwalters in forum Excel General
    Replies: 1
    Last Post: 01-11-2017, 09:39 AM
  4. [SOLVED] Calculating time difference?
    By devpp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2013, 02:31 AM
  5. Calculating time difference
    By TomBP in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-02-2010, 04:59 AM
  6. Calculating time difference
    By Sibrulotte in forum Excel General
    Replies: 0
    Last Post: 07-28-2009, 09:14 AM
  7. Calculating time difference between two days capturing the overnight time.
    By Monica_La in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-08-2007, 11:22 AM

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