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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduling visits

Status
Not open for further replies.

Junior1

MIS
Jan 12, 2000
2
AU
I am wanting to calculate the next service date based upon a service interval in days. This I can do using a query by simply adding the last service date and the service interval in days.<br>
<br>
However, I am wanting to exclude non working days (ie. weekends). If the next service date occurs on a non working day (ie Saturday or Sunday), I want the next service moved to the next working day (ie. Monday)
 
Look at the Date functions i.e. &quot;DateSerial&quot;<br>
here is an example that finds a Friday I had on hand<br>
Friday is the 4th day of the week<br>
So change the Num3 to a &quot;2&quot; I think is Monday.<br>
<br>
Function ThisFriday()<br>
Year1 = Year(Now)<br>
Month1 = Month(Now)<br>
Num3 = 4<br>
ThisFriday2 = DateSerial(Year1, Month1, Val(Format$(ThisMonday2, &quot;dd&quot;)) + Num3)<br>
Debug.Print &quot;ThisFriday2 &quot;; ThisFriday2<br>
ThisFriday = ThisFriday2<br>
End Function<br>
<br>
to exclude Holidays you may need a table that has all of the Holidays in it and then look up to make sure that your sunday is not one of those.<br>
<br>
like this<br>
Holiday<br>
12/25/00<br>
7/4/00<br>
<br>
and so forth<br>
Also check out these other Date functions<br>
<br>
Date, Now, Time<br>
DateAdd, DateDiff, DatePart<br>
DateSerial, DateValue<br>
TimeSerial, TimeValue<br>
Date, Time<br>
Timer<br>
<br>
hope this helps<br>
<br>

 
And of course if you could choose your number of days, you could add multiples of 7 to a previous service date and never run into a weekend. Of course there is still that holiday thing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top