Problem with DateAdd()

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

Access 2000:

The following code changes my date from 08 Mar 03 to 10 Mar 03.
What am I doing wrong?
TIA
Doug

Private Sub Expires_DblClick(Cancel As Integer)

If Me![Expires] < Date Then
Me![Expires] = DateAdd("Y", 2, Me![Expires])
Else
Me![Expires] = DateAdd("Y", -2, Me![Expires])
End If

End Sub
 
Access 2000:

The following code changes my date from 08 Mar 03 to 10 Mar 03.
What am I doing wrong?

Using "Y" (day of the year) rather than "YYYY" (years).
 
Doug,

Reading between the lines of your post, I suspect what you really want
is to add 2 years to the Expires value. Am I right? If so, "y"
refers to "day of year". You need to use "yyyy", i.e....
Me![Expires] = DateAdd("yyyy", 2, Me![Expires])

- Steve Schapel, Microsoft Access MVP
 
Doug said:
Access 2000:

The following code changes my date from 08 Mar 03 to 10 Mar 03.
What am I doing wrong?
TIA
Doug
Thank you for your replies. I used "Y" because I consulted my Que
Book.
I've tried "YYYY" and it works like a charm.
Doug
 
Back
Top