Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date

Status
Not open for further replies.

slickp

Technical User
Feb 15, 2006
35
GB
Using Crystal 10, I have a date field, and in my report i need to add a formula that will add 5 business days to this date if it is retail or 30 business days to it if it is commercial. However as it is business days, i need to exclude sat and sun. Any ideas?

Cheers
 
Try this formula

WhileReadingRecords;
DateVar Array Holidays;
DateVar Target:={@StartDate}; // Put your field name in here
NumberVar Add:= 2; // put the number of days here to add (a positive number)
NumberVar Added := 0;

WHILE Added < Add
Do (target := target +1;
if dayofweek (target) in 2 to 6 and not (target in holidays)
then Added:=Added+1
else Added:=Added);
Target

See if that works. (Thanks to Ken Hamady)
 
Cheers mate, found the Ken Hamady site, that guy is a legend!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top