Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2013
    Posts
    5

    Question Unanswered: help me about calculations hous

    hello
    i want ask about calculation hours for schedule table. lets say how to calculate based on what i select from my schedule table for :
    no class: how many hrs
    lesson i got class: how many hours.. for example: 1+0.5= 1.5 hrs
    total of hours: which is based on "no class" + " lesson i got class" for example: 1+1+0.5= 2.5 hrs


    i need to someone to help me how to perform these calculations using access which i want to open schedule report which show the total hours of each this. is it using query or? can anyone tell me steps by steps how to do?


    Thanks
    Last edited by ultra5219; 05-24-13 at 10:04.

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    If i was doing it i would store it in mins the display it in hours

    TIME is a MOD 60

    so by storing the mins

    its easy just to add them up to get the total mins

    60+60+30+25+45 = 220

    now we go 220 / 60 and drop the bits after the dot we get 3 hole hours
    now lets work out the difference

    now if we go 3 * 60 = 180
    now what the difference between 220-180 = 40*

    so the answer is 3:40

    * this number will always be less than 60 part there of a hour

    stuff it here my code I use all the time.

    ill even got a SQL function hiding away in a server somewhere
    which does the same thing

    Code:
    Function MintoHrs(num)
    'if num="" then num = 0
    If num < 60 Then
    MintoHrs = "00:" & DIG(num)
    Else
    hh = Int(num / 60)
    temp = (hh * 60)
    MintoHrs = DIG(hh) & ":" & DIG((num - temp))
    End If
    End Function
    
    Function DIG(num)
     If Len(num) = 1 Then
      DIG = "0" & num
     Else
      DIG = num
     End If
    End Function

    how how to use it

    in a query

    HRS:MintoHrs([minsfeild))

    the a form / report

    =MintoHrs([minsfeild))

    2:30 = MintoHrs(60 + 60 + 30)
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    I agree with StePhan about storing everything in Minutes, for the stated reasons. Once you have the Total Minutes, parsing it into Hours and Minutes, ala HH:MM, is simple:

    Code:
    HoursMinutes = Format(TotalMinutes \ 60, "00") & ":" & Format(TotalMinutes Mod 60, "00")

    Linq ;0)>
    Last edited by Missinglinq; 05-25-13 at 00:59.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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