Calculated Field

cuttsy

The Great Pretender
Local time
Today, 06:27
Joined
Jun 9, 2004
Messages
164
This seems a daft question but I have searched the forums and can't find an answer so I hope someone can help me.

I have a table: Register(RegID, Pupil, Activity, Duration, Preparation)

I have a query that I want to calculate the total hours the pupil has spent on activities.

The Duration and Preparation fileds are held as number of minutes so for a 1 hour event the number 60 is held.

I have a query with 4 fields:
Pupil
SumofDuration
SumofPreparation
TotalHours = ([SumofDuration]+[SumofPreparation])\60

The problem I have is that TotalHours is calculating as an whole number.
e.g. I have a Record
Pupil = 701
SumofDuration = 270
SumofPreparation = 0
TotalHours = 4

But I want TotalHours = 4.5

I have set the Duration and Preparation field sizes to Decimal and Format to General Number.

I don't know what else to try.
 
Try either redefining your [SumofDuration], [SumofPreparation] , and TotalHours fields as decimals or doubles, or typecasting calculations:

TotalHours = (CDbl([SumofDuration])+CDBL([SumofPreparation]))\60
 
Last edited:
Couldn't get that to work.

I have tried it with a siple query and even this rounds to an Int.

Code:
SELECT PupilRegister.Pupil, PupilRegister.Activity, CDbl([Duration])\CDbl(60.0) AS Dur, CDbl([Preparation])\CDbl(60.0) AS Prep
FROM PupilRegister;

I'm getting very frustraited, It can't be this difficult to divide in access I must be missing something obvious.
 
Thanks, I just had this pointed out to me.
That was a giant pain in the ass!

I knew I was doing something daft.
Thanks.
 

Users who are viewing this thread

Back
Top Bottom