We have a database that records the ship date and receipt date and we are
trying to disregard weekends and holidays. The problem is that it only
disregards the first weekend and then the elseif is met and it quits. If a
transit goes over two weekends (for example, takes 14 calendar days in
transit), then only the first weekend is credited. How should the elseif
read? Here's what we have for January, for example:
Function IT(SDAY As Date, RDAY As Date)
If #12/24/2004# >= SDAY And #12/27/2004# <= RDAY Then
IT = ((RDAY - SDAY) - 4)
ElseIf #12/31/2004# >= SDAY And #1/3/2005# <= RDAY Then
IT = ((RDAY - SDAY) - 4)
ElseIf #1/8/2005# >= SDAY And #1/9/2005# <= RDAY Then
IT = ((RDAY - SDAY) - 2)
ElseIf #1/15/2005# >= SDAY And #1/16/2005# <= RDAY Then
IT = ((RDAY - SDAY) - 2)
ElseIf #1/22/2005# >= SDAY And #1/23/2005# <= RDAY Then
IT = ((RDAY - SDAY) - 2)
ElseIf #1/29/2005# >= SDAY And #1/30/2005# <= RDAY Then
IT = ((RDAY - SDAY) - 2)
Else: IT = RDAY - SDAY
End If
End Function
Lynn Trapp - 04 Feb 2005 14:29 GMT
Trying to maintain that function is going to be a nightmare, because you are
going to have to modify it everytime a new month rolls around. Let me
suggest you take a look at the following website and see if you can modify
the code to work for you.
http://www.mvps.org/access/datetime/date0006.htm

Signature
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
> We have a database that records the ship date and receipt date and we are
> trying to disregard weekends and holidays. The problem is that it only
[quoted text clipped - 19 lines]
> End If
> End Function