Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Counting Days
Message
From
17/10/2000 06:35:05
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
16/10/2000 14:53:20
Erin Eby
Mission Critical Software
Gainesville, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00429936
Message ID:
00430213
Views:
14
>Hi there. I tried to find the "Stupid Questions" category for this one, but it didn't exist. :) Is there a way to count the number of business days (which would be everyday but Sat. and Sun.) that have occurred from Jan. 1st to today? just wondering....tia.

My .2 cents Erin.
Do not depent on cdow() unless you always use localized versions. OTOH string operations would slow down calculation. There is already dow() instead. Instead of calculating with a loop you could directly query week() and multiply by workdays - IMHO faster.

lnFullWeeks = max(week(date(),1,2),0)
lnFirstWeekDays = max(8-dow(date(year(date()),1,1),2) - 2,0)
lnThisWeekDays = iif(week(date(),1,2)=1,0,min(dow(date(),2),5))
lnWorkDays = lnFullWeeks * 5 + lnFirstWeekDays + lnThisWeekDays

This calculates workdays excluding holidays.
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