The Boss needed more attention, I will resume this exploration very soon. There does not appear to be anything wrong with your method, I am just exploring minimalist alternatives.
Thanks Mike
>It appears you never did post the fixed code. BTW, what was wrong with the version I posted?
>
>>Thanks for the example Mike, I DO get 11 and I know the fix! I will post the abbreviated technique later today.
>>
>>Thanks
>>
>>Glenn
>>
>>>Hi Glenn
>>>
>>>Do you get 11 days for this? workdays({^2003-06-11},{^2003-06-04})
>>>
>>>>I do not understand!
>>>>
>>>>CLEAR
>>>>
>>>>ld={^2003/06/06}
>>>>hd={^2003/06/11}
>>>>
>>>>? INT( (hd - ld) / 7)
>>>>? IIF(DOW(ld,2) < 6, 6-DOW(ld,2),0)
>>>>? IIF(DOW(hd,2) < 6, DOW(hd,2),0)
>>>>
>>>>
>>>>
>>>>wks = 0
>>>>Days before = 1
>>>>Days after = 3
>>>>
>>>>ergo 4.
>>>>
>>>>How did you calculate
>>>>
>>>>5 + 3 + 3
>>>>
>>>>Notice I used dow(datevar,2) for Monday being the first day of the week.
>>>>
>>>>Glenn
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>Hi Glenn
>>>>>
>>>>>I'm getting 11 days. The last line of code equates to 5 + 3 + 3 which is 11.
>>>>>
>>>>>>When I run the code in this message with {^2003/06/06} and {^2003/06/11} I get 4. What do you get? I sure hope 4!
>>>>>>
>>>>>>Glenn
>>>>>>
>>>>>>>Hi Glenn
>>>>>>>
>>>>>>>I did copy your code. I made a typo in the dates I gave you. I used June 6, 2003 to June 11, 2003.
>>>>>>>
>>>>>>>
LPARAMETERS dDate1, dDate2
>>>>>>>LOCAL wks, wkd
>>>>>>>hd = MAX(ddate1,ddate2)
>>>>>>>ld = Min(ddate1,ddate2)
>>>>>>>
>>>>>>>wks = INT( (hd - ld)/ 7)
>>>>>>>
>>>>>>>* Return Weeks * 5 which is overal workdays
>>>>>>>* Adjust for starting day of the first week
>>>>>>>* And adjust for the last partial week
>>>>>>>
>>>>>>>RETURN ;
>>>>>>> INT(wks * 5 + ;
>>>>>>> IIF(DOW(ld,2) < 6, 6-DOW(ld,2),0) + ;
>>>>>>> IIF(DOW(hd,2) < 6, DOW(hd,2),0) )
>>>>>>>
>>>>>>>
>>>>>>>>You must not have copied my code from this page because with this code I get 4, not 11. I admit 4 is incorrect but I am still debugging. I will post an improved version in a few minutes.
>>>>>>>>
>>>>>>>>Thanks for the critique
>>>>>>>>
>>>>>>>>Glenn
>>>>>>>>
>>>>>>>>C O R R E C T I O N ----
>>>>>>>>
>>>>>>>>Fri - Mon - Tue - Wed
>>>>>>>>
>>>>>>>> 4 IS correct!
>>>>>>>>
>>>>>>>>>Glenn
>>>>>>>>>
>>>>>>>>>I see you're trying something like what I posted. I like how you're trying to reduce the code's length. But, given June 11, 2003 and June 6, 2003 your version returns 11 days. Counting the days on the calendar I get 5 days.
>>>>>>>>>
>>>>>>>>>The random testing makes it impossible to determine if one routine is faster than another.
>>>>>>>>>
>>>>>>>>>>Thanks, here is a newer version which also is based upon weeks but in a different way.
>>>>>>>>>>
>>>>>>>>>>LPARAMETERS dDate1, dDate2
>>>>>>>>>>LOCAL wks, wkd
>>>>>>>>>>
>>>>>>>>>>hd = MAX(ddate1,ddate2)
>>>>>>>>>>ld = Min(ddate1,ddate2)
>>>>>>>>>>
>>>>>>>>>>wks = INT( (hd - ld)/ 7)
>>>>>>>>>>
>>>>>>>>>>* Return Weeks * 5 which is overal workdays
>>>>>>>>>>* Adjust for starting day of the first week
>>>>>>>>>>* And adjust for the last partial week
>>>>>>>>>>
>>>>>>>>>>RETURN ;
>>>>>>>>>> INT(wks * 5 + ;
>>>>>>>>>> IIF(DOW(ld,2) < 6, 6-DOW(ld,2),0) + ;
>>>>>>>>>> IIF(DOW(hd,2) < 6, DOW(hd,2),0) )
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>On my computer (AMD 1.6g 256mb) a 100,000 randomized test took 2.031 seconds including the considerable overhead of the test itself.
>>>>>>>>>>
>>>>>>>>>>ld = RAND(-1)
>>>>>>>>>>nStart = SECONDS()
>>>>>>>>>>FOR i = 1 TO 100000
>>>>>>>>>> noffset = INT(RAND()* 36)
>>>>>>>>>> ld = GOMONTH(DATE(),1-noffset)
>>>>>>>>>> hd = GOMONTH(DATE(),noffset)
>>>>>>>>>> wkd = workdays(ld,hd)
>>>>>>>>>>ENDFOR
>>>>>>>>>>MESSAGEBOX('Execution time was '+TRANSFORM(SECONDS()-nstart)+' seconds')
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>What do you think of this version?
>>>>>>>>>>
>>>>>>>>>>Thanks
>>>>>>>>>>
>>>>>>>>>>Glenn
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>Glenn,
>>>>>>>>>>>
>>>>>>>>>>>That code will fail if the dates cross a year boundary or are more than a year apart.
>>>>>>>>>>>
>>>>>>>>>>>>I needed a solution to determine the number of workdays between two dates and have not been satisfied with the prevalent techniques.