Results 1 to 5 of 5

Calculate Start and End Time Stored as HH:MM when Shift extend past 00:00 (midnight)?

Threaded View

  1. #1
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Calculate Start and End Time Stored as HH:MM when Shift extend past 00:00 (midnight)?

    Hi all,

    I hope you can help me.

    I have a simple calculation error due to, what I believe, is a format issue.

    Detail:

    i have two fields used for capturing a start and end time - txtWorkShiftStart and txtWorkShiftEnd. The format of these two fields are HH:MM. To calculate the total shift time, one would subtract the two values (End - Start).

    Here is the code i use for the calculation:

    ws.Cells(rowToEdit, 138).Value = Format(CDate(Me.txtWorkShiftEnd.Value) - CDate(Me.txtWorkShiftStart.Value), "HH:MM")
    This seems to work fine, until you have a shift starting before 00:00 (midnight) and end after 00:00 (midnight).

    Example:

    04:00 - 20:00 = 16:00 WRONG REMEMBER: it is a shift that started at 20:00 and ended 04:00 the next morning

    It should be :

    04:00 - 20:00 = 08:00 CORRECT REMEMBER: it is a shift that started at 20:00 and ended 04:00 the next morning

    i thank you in advance!
    Last edited by onmyway; 03-31-2015 at 02:30 PM.
    Sharing knowledge, can be likened to taking another person's hand, and pulling them up to a higher level -- onmyway

    If I was helpful, please remember to click on * Add Reputation below

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Text Time to Excel Format, Then Sort Time Past Midnight
    By BuntyMac in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-27-2014, 03:13 AM
  2. [SOLVED] Calculating shift totals and breaks past midnight
    By mazlou in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-16-2013, 12:49 AM
  3. [SOLVED] Current formula not able to calculate past midnight.
    By impresso in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-16-2013, 05:31 PM
  4. Replies: 4
    Last Post: 01-11-2012, 07:59 PM
  5. Calculate time which is past midnight
    By stoey in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 08-25-2011, 12:11 PM

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