+ Reply to Thread
Results 1 to 7 of 7

Calculating Time After Midnight and Convert Timezone

  1. #1
    Registered User
    Join Date
    01-24-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Calculating Time After Midnight and Convert Timezone

    Hi,

    I'm creating a schedule for work and have an issue calculating the time difference if past midnight, then converting it to EST. The thing that baffles me is it's fine in Google sheets, but I get ######### in Excel.
    Screen Shot 2017-10-30 at 20.44.29.png

    I've linked the sheet to my google drive here.


    Thanks for your help in advance!!!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculating Time After Midnight and Convert Timezone

    It's better if you upload the workbook here.

    Are you trying to calculate the Fonish time from a start time & duration, or calculate a duration from start/end times?

    The way I always approach this common problem is to add an IF function that tests for the end time being < than the start time and if so add 24 hours, the default being add zero hours.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Calculating Time After Midnight and Convert Timezone

    Hi purevibe and welcome to the forum,

    Excel has a problem with negative time or negative dates. Try this...

    =If (Answer < 0, -Answer, Answer)
    or use the ABS() function
    =ABS(Answer)

    https://support.microsoft.com/en-us/...signs-in-excel
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Calculating Time After Midnight and Convert Timezone

    Excel when dealing with DateTime values, will not accept negative values.

    From the looks of it, Google sheet has logic built in to wrap negative time into previous 24 hour cycle.

    What you can do is add date portion to time value to avoid negative time value. Or when the calculation results in negative value, add 1 (i.e. 24 hours) to time value.

    =IF(C9="","",IF((C9-'Schedule 16 Oct'!$B$13)<0,C9+1-'Schedule 16 Oct'!$B$13,C9-'Schedule 16 Oct'!$B$13))
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculating Time After Midnight and Convert Timezone

    You can use MOD function to get the correct duration between two times even when the period crosses midnight, e.g. with start time in A2 and end time in B2

    =MOD(B2-A2,1)

    That will also work when subtracting hours for timezone change, e.g.

    =MOD("01:00"-"4:00",1)

    format as time to get 21:00
    Audere est facere

  6. #6
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,629

    Re: Calculating Time After Midnight and Convert Timezone

    Try this, simple one

    If C2 is start time and D2 is finish time

    =IF(D2>=C2,D2-C2,1-C2+D2)

    Format as

    Custom --> [h]:mm
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  7. #7
    Registered User
    Join Date
    01-24-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Calculating Time After Midnight and Convert Timezone

    Hi all,

    Thanks for the greeting and your help on this, everyone. I've used the formula from @CK76, which was great and noted the issue with Excel and negative 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. Calculating time difference over midnight!
    By sygazelle in forum Excel General
    Replies: 14
    Last Post: 05-28-2022, 04:20 PM
  2. [SOLVED] Calculating difference in time after midnight
    By alan peele in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-16-2013, 02:01 AM
  3. [SOLVED] Military Time Not Calculating after Midnight.
    By heresteve2 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-04-2013, 06:34 PM
  4. Calculating Time Worked when Clocking out after Midnight
    By tstjuste in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-27-2013, 03:05 PM
  5. [SOLVED] Calculating time that goes past Midnight
    By jonvanwyk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-27-2013, 04:14 PM
  6. Calculating time after midnight
    By ryangodammit in forum Excel General
    Replies: 5
    Last Post: 12-09-2008, 11:57 PM
  7. Calculating Time Past Midnight
    By Darren in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-13-2006, 11:03 AM
  8. Replies: 3
    Last Post: 01-17-2006, 01:55 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