+ Reply to Thread
Results 1 to 18 of 18

Calculating time on site from a 24 hour clock

  1. #1
    Registered User
    Join Date
    03-07-2013
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    7

    Calculating time on site from a 24 hour clock

    I am exporting from a database into an excel file.
    It provides me with On Site and Off Site times, but I require the time spent on site. The 24 hr clock does not export with colons, eg
    On Site[INDENT]Off Site[INDENT]Time On Site
    2103[INDENT] 2214[INDENT] ?
    Is there a formula which can calculate the time spent on site, and then if it exceeds 30 minutes?

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Calculating time on site from a 24 hour clock

    Hi and welcome to the forum

    It would be easier to offer a suggestion if we could see some samples of the actual data you are working with
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    03-07-2013
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculating time on site from a 24 hour clock

    I have a attached an example document.
    Attached Files Attached Files

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Calculating time on site from a 24 hour clock

    Looking at your data, you can just use...

    =E2-D2

    Make sure you format the cell to number (or general) - it is currently text

  5. #5
    Registered User
    Join Date
    03-07-2013
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculating time on site from a 24 hour clock

    Sorry not that simple, though the 24hr clock presents in a decimal format, an hour still only has 60 minutes, therefore eg on at 0053 off at 0101 is in fact only 8 minutes on site, though the formula suggests 48. I originally played with subcontracting 40 from each result, but that would only apply to when the Time Off Site goes into another hour period as per above

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Calculating time on site from a 24 hour clock

    ok yes, sorry, I see that. try this instead....

    =(TIME(VALUE(LEFT(E2,2)),VALUE(RIGHT(E2,2)),0)-TIME(VALUE(LEFT(D2,2)),VALUE(RIGHT(D2,2)),0))
    format as time minutes:seconds....30:55.2

  7. #7
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Calculating time on site from a 24 hour clock

    Hi jatacake

    Also another way as below and format the cells as "mm:ss" or "hh:mm:ss" if required.
    =MOD((REPLACE(E2,4-1,0,":")+0)-(REPLACE(D2,4-1,0,":")+0),1)
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  8. #8
    Registered User
    Join Date
    03-07-2013
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculating time on site from a 24 hour clock

    Thanks for the reply.
    I have attached the spreadsheet with the formula inserted, the result is not what I need, ie I have inserted what the actual answers are, ie calculated manually. Do you think there is a way to achieve this?
    Attached Files Attached Files

  9. #9
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Calculating time on site from a 24 hour clock

    Look at the attachment below, I added a column just to check against your results, and custom formatted the cells as ' [m] ', without the (') apostrophes or spaces

    the formula used was :
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    it may be overkill, but it insured that they came out as valid times

    Hope this helps
    Attached Files Attached Files
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  10. #10
    Registered User
    Join Date
    03-07-2013
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculating time on site from a 24 hour clock

    Fantastic, works fine. Thanks for all your time

  11. #11
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Calculating time on site from a 24 hour clock

    You are welcome

    Please remember to mark the thread as solved if you are satisfied with your solution :
    To mark thread "Solved", go to the top of the thread,click "Thread Tools",click "Mark as Solved"

  12. #12
    Registered User
    Join Date
    03-07-2013
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculating time on site from a 24 hour clock

    Thanks and have done.
    As a side note, if I was only wanting to record results in excess of 30 min, eg as per attached
    Attached Files Attached Files

  13. #13
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Calculating time on site from a 24 hour clock

    Try this in H2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Drag down

    Hope this helps

    EDIT-

    Added the file
    Attached Files Attached Files
    Last edited by dredwolf; 03-10-2013 at 11:27 PM.

  14. #14
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Calculating time on site from a 24 hour clock

    =max(g2*1440-30,)

  15. #15
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Calculating time on site from a 24 hour clock

    mama always knows best

  16. #16
    Registered User
    Join Date
    03-07-2013
    Location
    Newcastle
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculating time on site from a 24 hour clock

    jatacake.sol1 (1).xlsDredwolf, I appologise, but I have found an error, I have attached the spreadsheet showing the example.
    It seems if the time on site progresses over midnight, an error is produced.
    Appreciate any assistance you can offer?

  17. #17
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Calculating time on site from a 24 hour clock

    okay then...try this in G2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    drag down

    Hope this helps

    EDIT_
    if you got some that go beyond 23.59 hrs, then you are going to have to redesign the sheet, the way it is laid out at this time does not allow for that,...
    Attached Files Attached Files
    Last edited by dredwolf; 03-11-2013 at 02:25 AM.

  18. #18
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Calculating time on site from a 24 hour clock

    @ jatacake

    Perhaps you need to read the replies carefully.
    the result is not what I need
    Post #6 & #7 gave you the correct answers.
    Instead of formatting as mm:ss all you needed to do format as [m] or for decimal time multiplied by 1440.

    jatacake.sol1 (1).xlsDredwolf, I appologise, but I have found an error, I have attached the spreadsheet showing the example.
    It seems if the time on site progresses over midnight, an error is produced.
    Appreciate any assistance you can offer?
    The answer for this error was in post #7!
    =MOD((REPLACE(E2,4-1,0,":")+0)-(REPLACE(D2,4-1,0,":")+0),1)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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