calculate time in access

G

Guest

I am a new use and having difficulty in calculating a time as follows. I
have a table with the following "Hours", "Rate". The hours can be 15 mins
upwards to 12 hrs 15 mins and the rate can be 1,1.33,1.5 or 2. I am trying
to calculate the accrued time by multiplying the Hours by the Rate which I
will place on a Form. I have set up a query which seems to carry out the
calculation but gives the answer in a decimal (I presume part of a day having
read a number of other questions), but I need the answer in Hours/Mins. Any
suggestions and is this the best option?
 
G

Guest

Calculate the difference in minutes, then convert it to hours and minutes.
You are probably not using the datediff function to get the initial value.

TimeInMinutes = DateDiff("n", StarTime, EndTime)
Now, to convert it to hours and minutes:

HoursTime = TimeInMinutes \ 60
MinutesTime = TimeInMinutes Mod 60

The \ operator returns on the integer part of a division
The Mod operator returns on the remainder part of a division.
 
A

Al Camp

I'm assuming you have calculated the hours correctly, and have come up with something like
7.9 as a result. (say that's named TotalTime)
To convert that to Hours and Minutes...

= Int([TotalTime]) & " hrs " & ([TotalTime]-Int([TotalTime]))*60 & " mins "

that should yield...
7 hrs 54 mins
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top