# handling elapsed time data

B

I am trying to import and run calculations on data dealing with total time
logged into a phone system for a group of users. the data is in the following
format:

User Date Total Time
user1 1/1/10 7:45:32
user1 1/2/10 6:31:45
user2 1/1/10 8:05:45

I have found many suggestions for how to calculate elapesd time, but cannot
seem to find how to store/format data already in this format. I am needing to
store the data this way in the table so I can run totals for users/date
ranges. Any suggestions?

D

#### Dirk Goldgar

I am trying to import and run calculations on data dealing with total time
logged into a phone system for a group of users. the data is in the
following
format:

User Date Total Time
user1 1/1/10 7:45:32
user1 1/2/10 6:31:45
user2 1/1/10 8:05:45

I have found many suggestions for how to calculate elapesd time, but
cannot
seem to find how to store/format data already in this format. I am needing
to
store the data this way in the table so I can run totals for users/date
ranges. Any suggestions?

I usually store the elapsed time as a Long Integer field representing a
count of the smallest unit of time I need to represent. In you example,
does "7:45:32" represent 7 hours, 45 minutes, and 32 seconds? In that case,
I'd store a count of seconds, so 7:45:32 would be

7 hours * 3600 seconds per hour = 25200 seconds
45 minutes * 60 seconds per minute = 2700 seconds
+
32 seconds
----------------------------------------------------------------------------
27932
seconds

Please pardon me if if that doesn't line up right.

For display purposes, you might write a function that takes the
ElapsedSeconds field and computes a formatted string in hh:mm:ss format.

For import purposes, you might write a function that takes a string in
hh:mm:ss format and returns the number of seconds that represents.

If the total times you need to represent exceed the maximum capacity of a
Long Integer field, you could use Currency or Decimal data type instead.

D

#### Daryl S

If you can work with decimal hours, that might be one way to store your
values. That would be a numeric field, and is 24 times the value calculated
as the time difference. So the Total Time of 7:45:32 would be 7.75889 hours
(just over 7 3/4 hours); 6:31:45 would be 6.52917 hours (just over 6 1/2
hours), etc. Being a numeric field, you can add and subtract hours easily.
You might get a weekly value of 41.365 hours for a user, which would be OK.

To set this up, just add another column to your table that is numeric
(single or double). Run an update query that takes your 'Total Time' column
and multiplies it by 24 and places the result in the new decimal hours
column. Depending on your needs, you can remove the total time column once
your code is set up to regularly populate the decimal hours column.

Hope that helps!

B

Thank you! I was hoping there was an easier way, but I will deff try this. I

B

Thank you! I was hoping there was an easier way, but I will deff try this. I

B