1. Registered User
Join Date
Feb 2013
Posts
5

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 09:04.

Join Date
Feb 2004
Location
New Zealand
Posts
1,477
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*

* 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)

3. Moderator
Join Date
Jun 2005
Location
Richmond, Virginia USA
Posts
2,764
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-24-13 at 23:59.

#### Posting Permissions

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