Thanks to all. The weekdays function works nicely, but upon examination I can't really use it since some of the reported labor *could* be from a weekend day. In addition, we decided that to evaluate the cycle time, we need to include the weekend days in the analysis since they are available days.
>Phil,
>
>You can combine David's idea with Walter's WeekDays() function from
Re: New WeekDays function Message #
822122create cursor x1 ( wo i, punch d )
>
>insert into x1 values ( 1, {^2005-1-1} )
>insert into x1 values ( 1, {^2005-1-6} )
>insert into x1 values ( 1, {^2005-1-8} )
>insert into x1 values ( 2, {^2005-1-3} )
>insert into x1 values ( 2, {^2005-1-6} )
>
>select wo, ( max( punch ) - min( punch ) ) + 1 as duration, ;
> WeekDays(min( punch ), max( punch )) ;
> from x1 ;
> into cursor howlong ;
> group by wo
>
>RETURN
>
>FUNCTION WeekDays(dDate1, dDate2)
>LOCAL nDays
>
>nDays = ABS(dDate1-dDate2)+1
>
>RETURN nDays - INT(nDays/7)*2 - SIGN(EVL(DOW(MIN(dDate1,dDate2),2)-7,-1) + (nDays % 7)) -1
>
>>I have a file with individual labor punches on work orders.
>>
>>WO Date
>>1 1/1/05
>>1 1/6/05
>>1 1/8/05
>>2 1/3/05
>>2 1/6/05
>>etc
>>
>>I want to calculate the number of days each work order was open by looping through the records. I am struggling with is how to do this for each work order and then output the work order number and cycle time days to a second table for reporting. The cycle time has to include the start and stop day too.
>>
>>Work Order Cycle Time
>>1 8
>>2 4
>>
>>As a secondary question - is there an easy way to count only WEEKDAYS?
>>
>>TIA
Phil Thomas
http://phillipdthomas.comNever let your energy or enthusiasm be dampened by the discouragements that must inevitably come.....