Jul 23, 2003 #1 80805157 Programmer Jun 18, 2003 4 TR Hi; How do I calculate the number of weekdays between two date fields?
Jul 27, 2003 #2 ABOzIT IS-IT--Management May 1, 2003 226 JP Put the following formula as the default value of a computed number field StartingSaturDay:=@If( @Weekday(dtStartDate) < 7; @Adjust(dtStartDate;0;0;(7-@Weekday(dtStartDate));0;0;0); dtStartDate); StartingSunday:=@If( @Weekday(dtStartDate) > 1;@Adjust(dtStartDate;0;0;(8-@Weekday(dtStartDate));0;0;0); dtStartDate); EndingSaturDay:=@If( @Weekday(dtEndDate) < 7;@Adjust(dtEndDate;0;0;-(@Weekday(dtEndDate));0;0;0); dtEndDate); EndingSunday:=@If( @Weekday(dtEndDate) > 1;@Adjust(dtEndDate;0;0;-(@Weekday(dtEndDate) - 1);0;0;0); dtEndDate); TotCount:=((((EndingSaturDay - StartingSaturDay)/86400)/7) + 1) + ((((EndingSunday - StartingSunday)/86400)/7) + 1); TotalDays := (dtEndDate - dtStartDate) /86400 + 1; Weekday := TotalDays - TotCount; Weekday ___________________________________ dtStartDate is the first date in the range dtEndDate is the last date in the range Hope this helps Upvote 0 Downvote
Put the following formula as the default value of a computed number field StartingSaturDay:=@If( @Weekday(dtStartDate) < 7; @Adjust(dtStartDate;0;0;(7-@Weekday(dtStartDate));0;0;0); dtStartDate); StartingSunday:=@If( @Weekday(dtStartDate) > 1;@Adjust(dtStartDate;0;0;(8-@Weekday(dtStartDate));0;0;0); dtStartDate); EndingSaturDay:=@If( @Weekday(dtEndDate) < 7;@Adjust(dtEndDate;0;0;-(@Weekday(dtEndDate));0;0;0); dtEndDate); EndingSunday:=@If( @Weekday(dtEndDate) > 1;@Adjust(dtEndDate;0;0;-(@Weekday(dtEndDate) - 1);0;0;0); dtEndDate); TotCount:=((((EndingSaturDay - StartingSaturDay)/86400)/7) + 1) + ((((EndingSunday - StartingSunday)/86400)/7) + 1); TotalDays := (dtEndDate - dtStartDate) /86400 + 1; Weekday := TotalDays - TotCount; Weekday ___________________________________ dtStartDate is the first date in the range dtEndDate is the last date in the range Hope this helps