Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add Work days to a date
Message
From
05/04/2007 12:16:51
 
 
To
02/04/2007 11:40:01
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01211326
Message ID:
01212570
Views:
16
This message has been marked as a message which has helped to the initial question of the thread.
Hi James,

See below.

Regards,
Sergey
*=============================================
FUNCTION WorkDate(d0, nDays0)
* Returns the date. For nDays0 not equal zero
* the date range d0 - WorkDate(d0, nDays0)
* has |nDays0| working days, or
*
* ABS(nDays0) = WorkDays(d0, WorkDate(d0,nDays0))
*
* There is no sense when nDays0 equal zero. In this case
* the function returns d0.
*
* Sergey Karimov

LOCAL nDow, nDays

nDow= DOW(d0,2)
nDays= nDays0 - SIGN(nDays0)

RETURN d0 + nDays0 + INT(nDays/5)*2;
          + IIF(nDays0>0, SIGN(nDays%( 5)+nDow-5.5) + SIGN(7-nDow),;
            IIF(nDays0<0, SIGN(nDays%(-5)+nDow-0.5) + SIGN(6-nDow),;
                          1)) - 1

*=============================================
FUNCTION WorkDays(d1, d2)
* Returns the number of working days (Mondays - Fridays)
* in the date range d1 - d2.
*
* This function evolved from Mike Yearwood's function
* WEEKDAYS.PRG, see:
* http://www.finn.wikis.com/wc.dll?Wiki~Weekdays~VFP
* as well as from its modifications published on
* www.levelextreme.com.
*
* Sergey Karimov

LOCAL nDays, nDow

nDays= ABS(d1-d2)+1
nDow= 7-DOW(MIN(d1,d2),2)

RETURN nDays - INT(nDays/7)*2 - SIGN(nDays%7-nDow) - SIGN(nDow)
>Hi All
>
>Anyone have a good program to add the number of workdays to a date without looping through the dates? I am not worried about holidays and such. Just Monday through Friday.
>
>Thanks.
Previous
Reply
Map
View

Click here to load this message in the networking platform