Anthony Parker
Anthony Parker

Reputation: 21

Invalid procedure call or argument with DateAdd VBA MSACCESS

Attempt creating a function that would add 100 years to improperly stored dates to correct them , ie 5/10/2016 is stored 5/10/1916 and needs to be converted to 5/10/2016. The function I wrote fails at the line with DateAdd in it.

Function CORRECTDATE(INPUTDATE As Date) As Date

    If IsDate(INPUTDATE) Then

        If INPUTDATE >= #1/1/1900# Then
          CORRECTDATE = DateAdd(yyyy, 100, INPUTDATE)
        Else
          CORRECTDATE = INPUTDATE
        End If

    Else
        CORRECTDATE = Null
    End If

End Function

Upvotes: 0

Views: 1483

Answers (1)

zmechanic
zmechanic

Reputation: 1990

You need quotation marks around yyyy:

CORRECTDATE = DateAdd("yyyy", 100, INPUTDATE)

Upvotes: 1

Related Questions