cancel
Showing results for 
Search instead for 
Did you mean: 

how to calculate the time spent producing the order ?

Former Member
0 Kudos
69

Here what I am trying to do is calculate the time so that if the EMTRNC is one of these codes, it is when the worker started to work on the order and the time we have as EMTRT. then we have the end time if the code is ECT which has a time also. the end time of the task. I have code to calculate hours from these minutes but how would you do the basic subtract here? and at which point?

shared numbervar TotalMin:=TotalMin;

shared numbervar endtime:=0;

shared numbervar CalTime:= CalTime;

if {EMPHISTL1.EMTRNC} in ('REL' 'EBC' 'EBV' 'EBA' 'BOM' 'BOO' 'BSB')

and {EMPHISTL1.EMPDPT} in '422' '2'

then

    TotalMin:= {EMPHISTL1.EMTRT};

//

if {EMPHISTL1.EMTRNC} = 'ECT'

then

    endtime:= {EMPHISTL1.EMTRT};

View Entire Topic
abhilash_kumar
Active Contributor
0 Kudos

Hi Paul,

Try this please:

shared timevar startTime;

shared timevar endTime;

shared numbervar CalTime;

shared numbervar interval;

if {EMPHISTL1.EMTRNC} in ['REL','EBC','EBV','EBA','BOM','BOO','BSB'] and {EMPHISTL1.EMPDPT} in ['422','2']

then

    startTime:= {EMPHISTL1.EMTRT};

if {EMPHISTL1.EMTRNC} = 'ECT'

then

    endTime := {EMPHISTL1.EMTRT};

interval := startTime - endTime; //time in seconds

NumberVar Hours   := Truncate (interval/3600);

NumberVar Minutes := Truncate (Remainder (interval,3600)/60);

NumberVar Seconds := Remainder (interval,60) ;


Totext (Hours,0,"") + ':'+ Totext (Minutes,0,"") + ':' + Totext(Seconds,0,"")


-Abhilash