Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Work days between two dates - finally!
Message
From
09/06/2003 07:52:46
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
09/06/2003 07:42:03
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00797684
Message ID:
00797907
Views:
21
>Hi Cetin,
>
>What was the error in Message #791711 ?
>for {^2003/6/15},{^2003/6/15} return -1, correct is 0.
>
>Last program:
>for {^2003/6/14},{^2003/6/16} return 2, correct is 1.
>
>Fabio

Good catch :)
lparameters td1, td2, tnWorkDaysInWeek
* First day of workday is Monday - 2
Local lnDays
If td2 < td1
	Local ldTemp
	ldTemp = td1
	td1 = td2
	td2 = ldTemp 
endif
tnWorkDaysInWeek = iif(empty(tnWorkDaysInWeek),5,tnWorkDaysInWeek)
lnFullWeeks = floor((td2-td1)/7)
td1 = td1+lnFullWeeks*7
If Dow(td1,2) > tnWorkDaysInWeek
  td1 = Iif( Dow(td2,2) > tnWorkDaysInWeek, ;
  	td1 + Abs(Dow(td1,2)-Dow(td2,2)), td1 + 7-Dow(td1,2))
endif
lnAdd = Iif( Dow(td1,2) > tnWorkDaysInWeek, 0, 1 )

lnDays = Iif( Dow(td1,2) > Dow(td2,2), ;
	7 - lnAdd - Dow(td1,2) + Dow(td2,2), ;
	lnAdd + Min(Dow(td2,2),tnWorkDaysInWeek) ;
	- Min(Dow(td1,2),tnWorkDaysInWeek) )
return  lnFullweeks * tnWorkDaysInWeek + lnDays 
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform