Sum' Time

T

tryn2learn

Good afternoon,

I'm trying to sum time and i have very little expericen with code.
my fields are:
Oper Stop Time
Machine Run Time
Machine Delay Time
Machine Stop Time
Active Time (Machine Run Time + Machine Delay Time)
Idle Time (Oper Stop Time + Machine Stop Time)

how can I take the time enter to get the sum of total time that i need in
Hours: Minutes:Seconds

Thank you in advance
 
J

Jeff Boyce

First, are those fields Access Date/Time data type fields? If so, you need
to understand that Access Date/Time data type stored "point in time" data,
not "duration" data.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
T

tryn2learn

right now I'm still trying to set up the table and I can't even get it to
take the data i enter as 121:50:09.... I'm still stuck at the very start of
all this. i'll use what ever field type needed to get this to work.

thank you again,
 
B

Beetle

What is the real world method by which you arrive at these values?
And is that method going to be reflected in your database?

In other words, when an operator starts the machine, do they log the current
time, and then again log the current time every time they start/stop from
then
until the end of the process?

Or, do they simply record the total duration of each step of the process,
and not the actual time of day?

Finally, is the data going to be entered in your application in this same
manner?

__________

Sean Bailey
 
T

tryn2learn

I'm actaully entering the data manually (I pull Qtrly reports that give me
these times via a .txt file)

active time: 121:50:09
Idle time: 93:40:49
Total Time (Active time + total time) = 215:30:58) this is what I'm hoping
to get access to do.

i'm currently using a spreadsheet do these reports but due to so mucn manual
entry my thought is using access for it's forms to make it easier verses
using 8 different spreadsheets because we track time for different client and
it must be seperated on the final report.


i hope this is of some help
 
J

Jeff Boyce

We aren't there. You'll have to give us a bit more description if you want
specific suggestions.

I'll ask again, what data type are you using for that field?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

Ken Sheridan

I'd suggest storing the active and idle times each as three separate columns
(fields) of integer number data type, ActiveHours, ActiveMinutes,
ActiveSeconds, IdleHours, IdleMinutes and IdleSeconds. Make each a
'Required' column in table design to prohibit Nulls and give each a
DefaultValue property of zero. For data entry just group the controls bound
to each set of three fields together side by side so you can tab from one to
the next. You can then return the total time as a string by passing the
values of the six columns into the following function, which first converts
the times to seconds then adds them and then converts them to a string of
hours, minutes and seconds:

Public Function TotalTime(ActiveHours As Integer, _
ActiveMinutes As Integer, _
ActiveSeconds As Integer, _
IdleHours As Integer, _
IdleMinutes As Integer, _
IdleSeconds As Integer) As String

Dim TotalActiveMinutes As Long
Dim TotalActiveSeconds As Long
Dim TotalIdleMinutes As Long
Dim TotalIdleSeconds As Long

Dim TotalHours As Long
Dim TotalMinutes As Long
Dim TotalSeconds As Long

TotalActiveMinutes = (ActiveHours * 60) + ActiveMinutes
TotalIdleMinutes = (IdleHours * 60) + IdleMinutes

TotalActiveSeconds = (TotalActiveMinutes * 60) + ActiveSeconds
TotalIdleSeconds = (TotalIdleMinutes * 60) + IdleSeconds

TotalSeconds = TotalActiveSeconds + TotalIdleSeconds

TotalHours = TotalSeconds \ 3600
TotalMinutes = (TotalSeconds - (TotalHours * 3600)) \ 60
TotalSeconds = (TotalSeconds - (TotalHours * 3600)) - (TotalMinutes * 60)

TotalTime = TotalHours & ":" & _
Format(TotalMinutes, "00") & ":" & _
Format(TotalSeconds, "00")

End Function

Paste the function into a standard module in the database and call it in a
query, or a computed control in a form or report:

TotalTime([ActiveHours], [ActiveMinutes], [ActiveSeconds], [IdleHours],
[IdleMinutes], [IdleSeconds])

Ken Sheridan
Stafford, England
 
K

KC-Mass

Hi Jeff,

I have seen time data like this before. It was in SQL Server in an
application called MACCESS. Very strange - stored its field names not as
columns but as row headers and the data values were stored horizontally.
The people that had developed the Access appplication I worked on, imported
the data into an Access Date/Time field and they looked exactly as shown
below: sometimes hundreds of hours, tens of minutes and 10s of seconds but
it was an accurate representation of the elapsed time. I could not find a
way to do math with it though so I converted it all to hours with a formula
something like:
(Day(timefield)*24) + Hour(timefield) + (Minute(timefield)/60) +
(Second(timefield)/3600)

That worked but very strange stuff.

Regards

Kevin
 
J

Jeff Boyce

Kevin

I've run across that approach, too. Until I know for certain that the field
is/is not a Date/Time field, it's tough to suggest "how"...<g>

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

John W. Vinson

Thank you Jeff,

my apologies, yes the fields are Date and Time.

The names of the fields are irrelevant (and in this case, wrong; both Date and
Time are reserved words and bad choices for fieldnames).

What is the *datatype* of each field? Are they Text, Number, Date/Time?
 
T

tryn2learn

the data type is Date/Time

John W. Vinson said:
The names of the fields are irrelevant (and in this case, wrong; both Date and
Time are reserved words and bad choices for fieldnames).

What is the *datatype* of each field? Are they Text, Number, Date/Time?
 
J

Jeff Boyce

Thank you.

If you are storing "duration" data in an Access Date/Time field, you will
run into problems doing your calculations.

Date/Time fields store "point-in-time" data, not "duration" data.

You wouldn't try to "do math" on a text value, would you? Don't try to "do
math" on a "point-in-time" value (at least, don't try to add them up).

Good luck

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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