PDA

Click to See Complete Forum and Search --> : How to add time intervals


Oct 9th, 2000, 02:54 PM
Dear Sir/Madam

This is at a school. I worked on an invigilation timetable. everything else very fine except the total hours spend by each teacher invigilating. I have a query in which I have the duration of each examination from the following function

Format([Start_Time]-1-[End_Time], "Short Time")

Now what I am after is another expression or function that I can use in another query to add up the hours and minutes spend by each teacher invigilating exams.

Gots

HunterMcCray
Oct 10th, 2000, 12:45 AM
Originally posted by Gotora
Dear Sir/Madam

This is at a school. I worked on an invigilation timetable. everything else very fine except the total hours spend by each teacher invigilating. I have a query in which I have the duration of each examination from the following function

Format([Start_Time]-1-[End_Time], "Short Time")

Now what I am after is another expression or function that I can use in another query to add up the hours and minutes spend by each teacher invigilating exams.

Gots

Assuming that you stored the times as Date/Time or that they are in Date/Time Format then simply use DateDiff(). You can certainly write a routine to perform the same function, but why? If you are not using Date/Time format then I strongly reccomend that you do. The Date/Time data type is native to both ACCESS and VBx through the variant data type. The raw datatype of Date/Time is "Double" where the integer part is the "Date" and the decimal portion is the "Time". IE 24 hours ~ .999999999_. The routines that the simple DateX native functions use to calculate year, month, day, dayofweek, hour, min, etc are fairly straight forward, but using them ensures that you will get the right answers without having to write a bunch of code. Assuming that you are using Date/Time format then simply add the sums of DateDiff(). If you want to force data types then you can force your times to decimal format using a double data type, then Add them using simple addition, then use your format() function to give you a time format.

Hope This Helps,

Hunter