+ Reply to Thread
Results 1 to 6 of 6

Formatting Time into decimal?

  1. #1
    Registered User
    Join Date
    06-15-2018
    Location
    Gresham, OR
    MS-Off Ver
    2013
    Posts
    2

    Question Formatting Time into decimal?

    Not sure if this is the best place to post this question or if it is even possible in Excel. Is there a way to show time in a decimal point format but set it so that it can't go past 59 minutes versus 99? For example I want 2 hours 59 minutes to be represented as 2.59 and then if someone accidentally types in something over .59 (such as .65) it would round up? We moved to new time tracking system that tracks attendance to the minute versus rounding on time cards. Thanks!

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Formatting Time into decimal?

    Speaking in exact mathematical terms, no. Decimal representation is 0 to .99, not 0 to chronological limits, otherwise its not based on the decimal numbering system.

    You can however take the hours as hours and the minutes as minutes and represent them however you want. So if you have 6 hours and 45 minutes you can take those two numbers and display them any way you like, including as 6.45 which is not really the decimal representation (which would be 6.75). Displaying chronological time to appear like a decimal number without really being a decimal number will mean that we need to jump through some hoops/overcome some hurdles to get those results, as entering a value of 6.45 will be by default interpreted by Excel as a numeric decimal value representing 6 and 45/100, not 6 hours and 45/60 minutes.

    What is the advantage for you showing these chronological values in a decimal like format instead of as a time format? IE why not just do 6:45 instead of 6.45, as many people will assume 6.45 is decimal format and follows decimal rules (IE: they should enter 6.75 for 6 hours and 45 minutes).
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Formatting Time into decimal?

    This is one of those things that might seem like a good idea, but in reality would be best avoided. You could do it with data validation by using a custom rule like =MOD(A1,1)<0.60 where A1 refers to the cell that the time will be entered.

    Any subsequent calculations performed on times entered in this format will need to be done carefully to avoid errors as excel will still evaluate them as regular decimals, not as times!

    =DOLLARDE(A1,60)/24 will convert your decimals to real time to allow calculations to be performed, but each will have to be done individually, DOLLARDE will not accept multiple values.

  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: Formatting Time into decimal?

    Hi, welcome to the forum

    I echo the comments made above - excel is well capable of dealing with time, and has quite a few functions specifically designed to work with time. I always advice members that, if you are working with time, then stick with time in TIME format.

    Another regular comment I make is that what you need to understand about dates and times in excel is…

    a date is just a number representing the number of days passed since 1/1/900...and then formatted in a way that we recognize as a date. So, for instance, today (Fri 15 Jun 2018) is actually 43266

    Time is actually a decimal part of 1 (day), so 06:00 AM is 0.25, 12 noon is 0.5 and 18:00 (or 6 PM) is 0.75
    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

  5. #5
    Registered User
    Join Date
    06-15-2018
    Location
    Gresham, OR
    MS-Off Ver
    2013
    Posts
    2

    Re: Formatting Time into decimal?

    I am running into a few issues with doing it this way. The first issue I am running into is a need to be able to list a starting vacation balance of 160 hours for example. When I try to put in 160 into time format it changes it to 16:00. I am guessing this is because it cant go past 2 digits for the hour and/or cant go beyond what military time would be. The other issue I am having is it is sensitive about inputting time. If I accidentally typed a space or something after 8: when putting in 8 hours it zeros out or it wont calc with my sum if formula.

  6. #6
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Formatting Time into decimal?

    Quote Originally Posted by tragicus View Post
    The other issue I am having is it is sensitive about inputting time. If I accidentally typed a space or something after 8: when putting in 8 hours it zeros out or it wont calc with my sum if formula.
    Excel is a relatively precise tool, your input should if nothing else be consistent. "8: 00" and "8:00" are not the same thing, regardless of if you do time format or not. Likewise "8.00" and "8. 00" are not the same thing either.

    You can go over 24 hours using time by formatting as [h] or [hh], the square brackets tell Excel to allow hours beyond 24 hours.

    Time and dates are hard to understand at first in Excel. As FDibbins points out dates are actually serial numbers from 1/1/1900 and time is decimal values from 0-1 representing a 24 hour cycle.

    There are of course plenty of formulas for dealing with dates and times and there are mathematical ways to convert and manipulate times.

    When working with dates and times its often prudent to use actual date/times for specific times of the day or dates and to use regular numbers converted to date/time values (later) when the number is meant to stand on its own. As an example:

    If I wanted the number of hours and mins between 2 date/times I would have both date/times in date/time format and perform my calculations on them, then convert or represent the result however I want. IE:

    (date/time) - (date/time) = decimal value
    6/18/2-18 3:35 PM - 6/18/2018 9:35 AM = .25

    I can convert the .25 to hours by simply formatting the cell as [h], which returns 6 (hours) difference. Truth is 6/18/2018 3:35 PM is really as a date value = 43269.6493055556, likewise the same date at 9:35 AM = 43269.3993055556. The whole time we are just dealing with numbers that Excel formats for us to look like dates and times. So if I format the cell as [h] it doesnt magically make my .25 = 6, it just displays it as 6.

    As such, date and time are linked together. Even when you input a time in Excel formatted as time without you entering a date, one is assumed. So really, there is no such thing as time in Excel without dates. In other words there is no such thing as 6 hours. Its either a 6 that we as humans identify as 6 hours or its a decimal value representing 6 hours as part of a date/time value.

    So you can convert 160 "hours" to a decimal value representative of 160 hours as a date/time value or you can convert time values into a whole number or decimal value representing the hours and then calculate results using 160 as a number representing 160 hours with those other values and after getting the result either convert it to a date/time equivalent or leave it as a number that people identify as representing hours.

    So to my example, again the 6 formatted [h] is still actually .25, so if I wanted to subtract the 6 hours from my 160 hours, I cant just do the 160-cell (where cell has our .25 formatted [h]), as it would really do 160 (the number) - .25 (the decimal representing 6 hours in date/time context). What I would want to do is convert the .25 decimal representing date/time to a number representing the hours (6) by doing .25 * 24 = 6. We do this as .25 represents 1/4 of a full day which is 24 hours. Now we have an actual value of 6 (which we as people know is representing 6 hours) and can now subtract it from the 160 and get a result representing the number of hours left, even though to Excel it has no attachment to time, its just 154.
    Last edited by Zer0Cool; 06-18-2018 at 03:51 PM.

+ 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. Convert time to decimal value by formatting?
    By trstew in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 08-07-2016, 08:35 AM
  2. [SOLVED] Calculating Time worked in both decimal and time format.
    By danieloverton1984 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-19-2015, 07:11 AM
  3. [SOLVED] Converting an elapsed time in decimal number format to an actual time :S
    By Spicey_888 in forum Excel General
    Replies: 3
    Last Post: 07-20-2014, 08:53 PM
  4. Replies: 2
    Last Post: 04-19-2012, 10:34 PM
  5. Replies: 2
    Last Post: 10-12-2011, 10:54 AM
  6. Converting military time to decimal time not rounding correctly
    By Sean Anderson in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-23-2008, 09:12 PM
  7. [SOLVED] Decimal Formatting in Windows English vs European Formatting
    By Drummer361 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2006, 09:50 AM

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