+ Reply to Thread
Results 1 to 14 of 14

Date/Time formula

  1. #1
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Question Date/Time formula

    Hi,

    I have been asked to make some ammendements to a workbook currently in use.

    I have to calculate elapsed time, and my formula is giving me odd results. I have a start time (cell B5), and an end time (cell F5). The formula being used was =IF(F5>0,((F5-B5)*24)) which gave the correct result. The cell is formatted as general. It didn't alot for the situation where the end time has not happened yet.

    I changed the formula to =IF(F5>0,((F5-B5)*24),(K5-B5)*24) where cell K5 is the current time. The results are coming out with 6 - 9 decimal places. It makes no sense as I've tried setting the times to be exactly 24 or 48 hours to the minute. I've also tried replacing K5 in the formula to now(), but it didn't help.

    Does anyone have any ideas?

    Soma

  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: Date/Time formula not working

    Hi

    An uploaded sample workbook is worth a thousand words.

    Rgds
    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
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: Date/Time formula not working

    You're right Richard,

    I've attached a copy of the workbook. I've highlighted in red the fields that are giving me trouble.

    Soma
    Attached Files Attached Files

  4. #4
    Forum Contributor ptm0412's Avatar
    Join Date
    04-16-2008
    Location
    Vietnam
    MS-Off Ver
    Office 2003 and 2007
    Posts
    129

    Re: Date/Time formula not working

    Why don't you round the result?
    H5 = IF(F5>0, ((F5-B5)*24), ROUND((G5-B5)*24, 1))

    Or if you want to show the result as hh:mm, you could format it as custom: [hh]:mm
    Oldman Chatting: [email protected] Mailing: [email protected]

  5. #5
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: Date/Time formula not working

    Thank you,

    The rounding off worked.

    I had tried formatting it as [hh]:mm, but that made a bigger mess. I have no idea why.

    No problems though. The rounding off gave me the results I needed.

    Thanks again
    Soma

  6. #6
    Forum Contributor marc5354's Avatar
    Join Date
    11-10-2009
    Location
    India
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    217

    Re: Date/Time formula not working

    please find, hope this will help

    ...Marc
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: Date/Time formula not working

    Thanks marc5354,

    I will try both methods.

    Soma

  8. #8
    Forum Contributor marc5354's Avatar
    Join Date
    11-10-2009
    Location
    India
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    217

    Re: Date/Time formula not working

    hmm i m not sure, but think it works...

    and let me know. if its working as according to your wish..

    ...Marc

  9. #9
    Forum Contributor ptm0412's Avatar
    Join Date
    04-16-2008
    Location
    Vietnam
    MS-Off Ver
    Office 2003 and 2007
    Posts
    129

    Re: Date/Time formula not working

    I am sorry for saying not clearly. If you use the custom format [hh]:mm, the formula will be:
    H5 =IF(F5="",G5-B5,F5-B5)

    See attached file.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: Date/Time formula

    Thank you all for your replies,

    I've tried the differnet methods, and here is what I'm coming up with. Both methods work find in the excel sheet, but I can't get the right format to come up in my form.

    I have a form that provides the data from all the calculation, and it doesn't matter which method I use, when I reference cell H5 in the form, it comes out looking horrible. In my current entry, cell H5 shows 13:12 hours, in the form it comes up as 0.55000000000291.

    This is the code in the Form

    Please Login or Register  to view this content.
    Where txtTimeSpent.Value is the value in cell H5

    Almost there, but not quite.

    Soma

  11. #11
    Forum Contributor marc5354's Avatar
    Join Date
    11-10-2009
    Location
    India
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    217

    Re: Date/Time formula

    Hello Soma

    Can you please help...????

    ...Marc

  12. #12
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: Date/Time formula

    Marc,

    You're suggestion work perfectly in the excel spreadsheet. What I'm having an issue with now is putting that time into a form using VBA.

    Soma

  13. #13
    Forum Contributor marc5354's Avatar
    Join Date
    11-10-2009
    Location
    India
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    217

    Re: Date/Time formula

    Anyway that is good, i am having some other issues in formula to get the difference between file received time and how to calculate remaining TAT (Turn Around Time).

    Can you please help, If Possible

    ...Marc

  14. #14
    Registered User
    Join Date
    08-15-2009
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Time Formula Not Calculating Same in All Cells

    This time sheet is not calculating time the same even though the formula's are exactly alike. It involves minutes converted to tenth's of an hour. One place it will calculate 15 minutes as .2 hours and others it will calculate 15 minutes to .3 hours. I have looked at it until I'm blind.

    I have the calculate options setup to calculate automatically and set precision as displayed is checked.

    I'd sure appreciate someone taking a look at it and letting me know what I need to do to fix this.
    Attached Files Attached Files

+ 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