PDA

Click to See Complete Forum and Search --> : Nasty Date issue


JohnAtWork
Jul 15th, 1999, 09:23 PM
I've got a nasty one for you. . .
I have a date issue where I have a received date (when goods come into door) and a floor date (When goods are available to be consumed on the production floor). The Floor date is nonexistent, and I need to calculate it.

There's a set number of days (contained in another field, DelayTime) that is the delay between the two dates, and allows calculation of Floor Availability.

The problem is that DelayTime is in business days, and no work is done on the weekend.

So if I have a DelayTime of 3 business days, goods come in the door on Thurs, I need it to set the date to Tues, not Sun.

Anyone have any nifty functions that calculate around weekends?


------------------
Legalese:
Anything I say on this forum is strictly my own opinion, and if I make a jerk out of myself, it has NOTHING to do with the company.

[This message has been edited by JohnAtWork (edited 07-16-1999).]

jim
Jul 25th, 1999, 10:50 PM
Public Function CalcBusDays(StartDate as Date, NumOfDays as Integer) as Date

Dim WorkDate as Date

WorkDate = StartDate
Do Until NumOfDays = 0

Add_Next_Date:
WorkDate = WorkDate + 1
If WeekDay(WorkDate) < 2 or WeekDay(WorkDate) > 5 Then Goto Add_Next_date

NumOfDays = NumOfDays - 1

Loop

CalcBusDays = WorkDate
Exit Function