on 12-29-2014 11:37 PM
I am calculating the time taken to complete a production order. I use this formula to get the time. The CR is grouped by Order#, Dept, Empid, and work code. Work codes are calculated according to a set (begin and end) and we have a list of all endings so we know which are a set.
This formula is working for a total of time per order but only where there is one employee on an order, but there can be more than 1. It does the last employee on the order.
shared numbervar OrderTime:=OrderTime;
if OrderTime>0 then
cstr(int(OrderTime/60)) & ":" & right( "00" & cstr(OrderTime mod 60),2);
---
order time is done in this formula which is done for each set of work codes.
shared numbervar OrderTime:=OrderTime;
shared numbervar StTime:= StTime;
shared numbervar EdTime:= EdTime;
shared numbervar finalTime:= 0;
shared numbervar empTime:=empTime;
shared numbervar TotalWTime:=TotalWTime;
shared numbervar DeptTime:=DeptTime;
if StTime>0 and EdTime>0 and len(cstr(StTime))=6 and len(cstr(EdTime))=6 then
finalTime:= (tonumber( mid(totext(EdTime,0,""),1,1)) * 60 + tonumber( mid(totext(EdTime,0,""),2,2)) ) - (tonumber( mid(totext(StTime,0,""),1,1)) * 60 +
tonumber( mid(totext(StTime,0,""),2,2)) );
if StTime>0 and EdTime>0 and len(cstr(StTime))=7 and len(cstr(EdTime))=7 then
finalTime:= (tonumber( mid(totext(EdTime,0,""),1,2)) * 60 + tonumber( mid(totext(EdTime,0,""),3,2)) ) - (tonumber( mid(totext(StTime,0,""),1,2)) * 60 +
tonumber( mid(totext(StTime,0,""),3,2)) );
if StTime>0 and EdTime>0 and len(cstr(StTime))=6 and len(cstr(EdTime))=7 then
finalTime:= (tonumber( mid(totext(EdTime,0,""),1,2)) * 60 + tonumber( mid(totext(EdTime,0,""),3,2)) ) - (tonumber( mid(totext(StTime,0,""),1,1)) * 60 +
tonumber( mid(totext(StTime,0,""),2,2)) );
if StTime>0 and EdTime>0 and len(cstr(StTime))=7 and len(cstr(EdTime))=6 then
finalTime:= (tonumber( mid(totext(EdTime,0,""),1,1)) * 60 + tonumber( mid(totext(EdTime,0,""),2,2)) ) - (tonumber( mid(totext(StTime,0,""),1,2)) * 60 +
tonumber( mid(totext(StTime,0,""),3,2)) );
if StTime>0 and EdTime>0 then
OrderTime:= OrderTime + finalTime;
if finalTime>0 then
empTime:=empTime+finalTime;
if finalTime>0 then
TotalWTime:=TotalWTime+finalTime;
if finalTime>0 then
StTime:=0;
if finalTime>0 then
EdTime:=0;
if finalTime>0 then
DeptTime:=DeptTime+finalTime;
if finalTime>0 then
cstr(int(finalTime/60)) & ":" & right( "00" & cstr(finalTime mod 60),2);
Your formula shows that you're processing order time by work code group - it will not work for the order group. However, if you want to get the total time for the whole order, you'll probably need to do something like this:
1. Get the minimum start time for the order group. (Use the actual Date field instead of the variables you're using above.)
2. Get the maximum end time for the order group. (Use the actual Date field instead of the variables you're using above.)
3. Subtract the start time from the end time.
4. Convert the result to your minutes and second format.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.