+ Reply to Thread
Results 1 to 2 of 2

Changing time to decimal

  1. #1
    Registered User
    Join Date
    05-29-2007
    Posts
    11

    Changing time to decimal

    Fairly simple problem I think, I have a list of times/dates. I use cells formatted as [hh]:mm with the formula =D343-D2 (which would be the last entry minus the first entry) to give me the range in hours (for example, right now it has been 65 hours and 22 minutes, 65:22, since the first entry).

    To perform some calculations I need to change that to decimal form (30 minutes becomes .50), right now I use the formula =HOUR(K2)+MINUTE(K2)/60, the problem is that it works if time is under 24 hours. However, right now it is showing 17.37, dropping the first 48 hours (if it goes over 24 hours, it drops that time and starts from 0).

    I could just manually add 24 hours every time it goes over (so right now I'm adding 48 to get it to display correctly), however, after a while this will become painful. Is there a better way to do this?

    Excel 2007 btw, thanks for any help you guys can give me.

    -Mike

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Changing time to decimal

    To subtract time values past midnight, use this process:

    1) subtract earlier time from later time
    2) add a formula to test if the later time is after midnight and the earlier time before midnight
    3) then multiply by 24
    4) format as General

    =((B2-A2) + (B2<A2)) * 24
    Last edited by JBeaucaire; 11-10-2009 at 01:54 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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