adding Hours and Minutes in a TIME FIELD

G

Guest

Dear Sir, i m working on a database in Access, which maintains the Study
hours of Students. How can i define a field in a table which can give me Sum
of Total Hours of a specific Student, or of all students At the end of the
month. How can i add Hours and Minutes of that Field in a report.


Regards
 
G

Guest

Ahmer said:
Dear Sir, i m working on a database in Access, which maintains the Study
hours of Students. How can i define a field in a table which can give me Sum
of Total Hours of a specific Student, or of all students At the end of the
month. How can i add Hours and Minutes of that Field in a report.

I'm no pro, but it sure sounds like you need a related table the study time
records.

Just off the top opf my head, I would have

tblStudent
StudentID
StudentName
StudentWhateverelse...

tblTime
TimeID
StudentID
StudyTime (h:mm format)
StudyDate (m/d/yy format...unless you're not American and want to do it
the correct way...yymmdd)
TimeWhateverelse...

From this, you can make reports to total study time for all students or any
particular student.
 
D

Douglas J. Steele

The only time-related data type in Access is the Date type, which isn't
intended to be used for time durations: it's supposed to be a timestamp
(specific point in time). That's because, under the covers, it's an 8 byte
floating point number where the integer portion represents the date as the
number of days relative to 30 Dec, 1899, and the decimal portion represents
the time as a fraction of a day.

What you should do is store the hours in an Integer field as the number of
minutes spent studying. You can then add together the number of minutes
spent. Write your own custom function to format total minutes to hh:nn, and
you should be fine.

Function FormatMinutes(TotalMinutes As Long) As String

FormatMinutes = Format(TotalMinutes \ 60, "0") & ":" & _
Format(TotalMinutes Mod 60, "00")

End Function
 

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

Top