Results 1 to 11 of 11
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Error In Adding Time

    Hi All



    When i add the "Accepted_Hours" (as per the below pic) the total should show as 32:22 instead its showing as 8:22, how can i rectify this error. Please help.Click image for larger version. 

Name:	5555555.jpg 
Views:	25 
Size:	38.7 KB 
ID:	31762

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Provide the query SQL statement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    i just typed =Sum([Accepted_Hours])

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    hours has a maximum of the number of hours in a day. Dates are a special form of double which are formatted to look like a date for the area of the world you are in.

    The bit before the decimal point represents the date (a number where 21/12/1899 is 0 and each day is incremented by 1 - today is 43091), the bit after the decimal point represents the time in seconds as a fraction of the number of seconds in a day (86400). So when you calculate a time difference (say between 9am and 12noon) this will be 0.5-0.375=0.125. If you have say 10 of these added together you will total 1.25 - which represents a day and 6 hours. You are seeing the 6 hours, not 30 hours.

    So you need a formula to convert the 1 part to hours. Easiest would be to multiply by 24 - so 1.25*24=30

    so try sum([accepted_hours])*24 and remove the date formatting. This will give you something like 32.366

    but now you need to convert the .366 to provide minutes

    To get the hours you would use the int function int(sum([accepted_hours])*24)

    then add a colon to the end

    then get the fraction to calculate the minutes

    (sum([accepted_hours])*24)-int(sum([accepted_hours])*24)

    and multiple by 60

    ((sum([accepted_hours])*24)-int(sum([accepted_hours])*24))*60

    so your total formula becomes

    int(sum([accepted_hours])*24) & ":" & ((sum([accepted_hours])*24)-int(sum([accepted_hours])*24))*60

  5. #5
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Your adding time parts of stored dates - once it gets past 24 hours and your formatting it as a time you'll start to see it can't display it as a time per se.

    To display it properly you'll need to get a bit obtuse. DateDiff("n",0,(Sum(Accepted_Hours))) will give you the total time in minutes.
    I'll let you fathom out where to go from there.

    Edit - Ajax gave you a much more complete explanation.

  6. #6
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Hi

    I need the time in hh:mm so i modified your formula as DateDiff("h",0,(Sum(Accepted_Hours))) but it gives the out put as 32.00 not as 32:22. How to correct this?

    or can use Round as below

    Round(int(sum([accepted_hours])*24) & ":" & ((sum([accepted_hours])*24)-int(sum([accepted_hours])*24))*60,1)

  7. #7
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Hi Guys

    Thanks a lot for your help.

    I just modified the Ajaz Code as below
    =Int(Sum([Accepted_Hours])*24) & ":" & Round(((Sum([Accepted_Hours])*24)-Int(Sum([Accepted_Hours])*24))*60,1)
    above formula it rounds up the value to 32:22.

    Thank You Very Much Guys.
    Last edited by Eranka; 12-22-2017 at 08:13 AM.

  8. #8
    Join Date
    Apr 2017
    Posts
    1,792
    It is a mystery for me, why MS doesn't include into Access same format types as it uses in Excel - "[h]:mm"/"[m]"/[d] hh:mm"/etc.. In Excel you can display the difference how OP wanted (32:22).

  9. #9
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Hi Guys

    Click image for larger version. 

Name:	666666.jpg 
Views:	18 
Size:	34.2 KB 
ID:	31890

    Please see above image. I am adding the time in above image. when add the total time it should be 23:26 instead its showing 23:43. How do correct this?

    The code i used is

    Code:
    =IIf(((Sum([Accepted_Hours])*24)<=24),(Sum([Accepted_Hours])*24),(Sum([Accepted_Hours])*24))

  10. #10
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Your IIf has the same result for true and false e.g. (Sum([Accepted_Hours])*24)
    Is that intended, it makes no sense?

    Are you sure that is the code used ? Access will normally only add up the data as presented?

  11. #11
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Then i tired with this. still not working.
    Code:
    IIf(((Sum([Accepted_Hours]))<24),(Sum([Accepted_Hours])),(Int(Sum([Accepted_Hours])*24) & ":" & ((Sum([Accepted_Hours])*24)-Int(Sum([Accepted_Hours])*24))*60))

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 12
    Last Post: 07-19-2015, 05:21 PM
  2. Adding & Loading Add-In at Run Time.
    By Robeen in forum Access
    Replies: 1
    Last Post: 01-28-2015, 09:48 AM
  3. Replies: 0
    Last Post: 07-16-2012, 05:42 AM
  4. Adding Time help
    By Bozilla in forum Forms
    Replies: 3
    Last Post: 11-08-2011, 09:18 AM
  5. Adding Time
    By jlclark4 in forum Queries
    Replies: 7
    Last Post: 05-04-2011, 10:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums