Thread: help me about calculations hous
05-23-13, 17:31 #1Registered User
- Join Date
- Feb 2013
Unanswered: help me about calculations hous
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?
Last edited by ultra5219; 05-24-13 at 10:04.
05-24-13, 07:53 #2(Making Your Life Easy)
Provided Answers: 10
- Join Date
- Feb 2004
- New Zealand
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
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
the a form / report
2:30 = MintoHrs(60 + 60 + 30)hope this help
See clear as mud
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
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
YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
05-25-13, 00:56 #3Moderator
Provided Answers: 19
- Join Date
- Jun 2005
- Richmond, Virginia USA
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:
HoursMinutes = Format(TotalMinutes \ 60, "00") & ":" & Format(TotalMinutes Mod 60, "00")
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