Results 1 to 9 of 9
  1. #1
    Lounger
    Join Date
    Oct 2001
    Location
    Bristol, Bristol, United Kingdom
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date / Time calculation (2000)

    OK - I give up! I want to work out the duration of an incident (i.e the number of hours and minutes from start to end - can be more than 24 hours) - I have a table with four columns (amongst others) - 2 show the start and end date and the other 2 show the start and end time. I have used =CONCATENATE(a1,a2) (for example) to combine the start date and start time together and the same for end date and end time. (This gives me the long decimal number). I figured I can them simply subtract the start date/time from the end date/time to get an answer.
    For the most part this works, but (of course!) there are several ridiculous answers (4000 hours!!!) I have played with the formatting (tried the [h] thing) but nothing will get rid of these odd answers.
    For info, I have copied and pasted the value (using the paste special) on some of these answers and found that the wrong answers are holding a date, whereas the correct answers simply hold a time. Also, if I show the duration in the text format (to show the decimal value), the wrongs answers are all over 1, and the correct answers under 1. If i knew what this meant I would be able to work it out I am sure....can anyone out there sus it out??
    Thanks for any help as always.

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date / Time calculation (2000)

    You are making it too hard on yourself. Look up the DATEDIF function in Excel Help, and use "the hh mm thing".
    Gre

  3. #3
    Lounger
    Join Date
    Oct 2001
    Location
    Bristol, Bristol, United Kingdom
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date / Time calculation (2000)

    Sorry - doesn't help!! Apart from that the "Help" function rarly provides any understandable "Help" and simply sends me in circles looking for what words mean (I may be synical here!), what about the times? I need an answer in hours and minutes, not days. (I mean on the spreadsheet here by the way...although the Help function does take days too!!!!)
    Maybe I have misunderstood though, do I simply type in =DATEDIF(a1,a2) and it will tell me the difference between cells a1 and a2? So would a TIMEDIF work therefore??
    I have to leave work now, but will return in the morning....thanks again for any and all help!

  4. #4
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date / Time calculation (2000)

    It would probably be best if you could post a small sample spreadsheet demonstrating the problem so that someone can work it over for you to see what is happening for you.

    Peter

  5. #5
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date / Time calculation (2000)

    Once you are down to less than a Day, the Hours and Minutes should be straightforward. It appeared that you were perhaps getting over-compex using CONCATENATE functions. The DATEDIF formula can be applied to the Days columns and then the simple difference in the Hours and Minutes columns can be added or subtracted as appropriate.

    What form are you storing your hours and minutes in? You may find it simpler to check for erroneous data if you combine your Days and Hours and Minutes into a single cell in MM/DD/YY hh:mm format. (This is one of the default Excel date formats.) It could be that you are arriving at 4000 hours becase some of your Hours and Minutes columns are being picked up as being (say) in the year 1900.

    HTH
    Gre

  6. #6
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date / Time calculation (2000)

    The way Excel keeps dates/times is in number of days since Jan 0, 1900 (Dec 31, 1899) as the integer part and fraction of the day for the time. Today (July 21, 2003) is the 37,823 day since Jan0, 1900. Noon today would be half of a day. Therefore, noon today is represented as 37,823.5 for an Excel date/time.

    In your application, you really should have the start date and time in one cell. However, if you truly have them entered and Excel dates and Excel times (and not as text values), you should be able to just add them together to get what you need.

    If we assume that the start date is in A1, the start time is in B1, the end date is in C1, and the end time is in D1, then the following formula should calculate the event time:

    <pre>=(C1+D1)-(A1+B1)
    </pre>


    If you just format that as a time, you will get the time modulo 24 hours. To get Excel to display elapsed times, you need to use a special format. Select Cells from the Format menu and then click on Custom in the list. In the "Type" box enter:

    <pre>[h]:mm
    </pre>


    with the brackets around the h. This will display the elapsed time in hours and minutes.
    Legare Coleman

  7. #7
    Lounger
    Join Date
    Oct 2001
    Location
    Bristol, Bristol, United Kingdom
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date / Time calculation (2000)

    Well I never! I knew it would be something simple!! This method works Legare and is very easy - didn't realise I could add a date and time together like that. (Also, my =CONCATENATE method seems to be working this morning too....don't know what that's about!? Maybe it saw this other way and figured out what it was meant to do!!!??)
    This way is much easier though, so thank you! It will come in useful!

  8. #8
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date / Time calculation (2000)

    Just curious... what is the significance of the brackets [ ] around the h?

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Date / Time calculation (2000)

    It's just a convention, I don't think that there is a deeper significance. [h] or [hh] in a custom number format stands for hours, but it is different from h or hh in that a number of hours above 24 can be displayed. h is used for a clock time, [h] for cumulating time.

    In the following, remember that Excel stores a date as a number of days and a time as a fraction of a day. So 12 hours is stored as 12/24 day = 0.5.

    <table border=1><td>Unformatted</td><td>h:mm</td><td>[h]:mm</td><td align=right>0.5</td><td align=right>12:00</td><td align=right>12:00</td><td align=right>1.0</td><td align=right>0:00</td><td align=right>24:00</td><td align=right>1.5</td><td align=right>12:00</td><td align=right>36:00</td></table>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •