01-09-14, 10:26 #1Registered User
- Join Date
- Jan 2004
Unanswered: Add if statement if date is blank
I got this function a while back from this forum, it looks good.
however, in some cases the STARTerDATE is blank.
what do I need to add to make the STARTerDATE = today (if its blank.
I assume its a simple if statement, but I don't know what it is.
Function NetWorkDays(STARTerDATE As Date, ENDerDATE As Date) As Integer
Dim TESTDATE As Date
NetWorkDays = 0
TESTDATE = STARTerDATE
While TESTDATE <= ENDerDATE
If Not ((Weekday(TESTDATE) = 7) Or (Weekday(TESTDATE) = 1)) Then
NetWorkDays = NetWorkDays + 1
TESTDATE = TESTDATE + 1
01-09-14, 10:57 #2Jaded Developer
Provided Answers: 59
- Join Date
- Nov 2004
- out on a limb
what you could/should always do is make certain values are 'sane'
there's so many ways of implementing that, but one way is to use the NZ function
Starterdate = nz(startdate,date()) 'test the start dtae has a value and if not use todays date
Enderdate = nz(enderdate,date())
'next check startdate is less than or equal to the enderdate
if starterdate> enderdate then starterdate=enderdate
'you can go further and check starterdate is a date
if not isdate(starterdate) then starterdate = date()
if not isdate(enderdate) then senderdate = date()I'd rather be riding on the Tiger 800 or the Norton