Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    115

    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.

    Thanks

    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
    End If

    TESTDATE = TESTDATE + 1
    Wend
    End Function

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •