Adding months to a previous date

  • Thread starter Thread starter Sharon
  • Start date Start date
S

Sharon

How do you add months to a date in the following code:

If [account_class] = 1 then
[Last Audit Date] = add 36 months (for next audit date)

If [account_class] = 2 then
[Last Audit Date] = add 24 months (for next audit date)

Last Audit Date Format: 06/30/2003
 
Sharon said:
How do you add months to a date in the following code:

If [account_class] = 1 then
[Last Audit Date] = add 36 months (for next audit date)

If [account_class] = 2 then
[Last Audit Date] = add 24 months (for next audit date)

Last Audit Date Format: 06/30/2003

Select Case [account_class]

Case 1
[Last Audit Date] = DateAdd("m", 36, [Last Audit Date])


Case 2
[Last Audit Date] = DateAdd("m", 24, [Last Audit Date])

' ... possibly other cases ...

End Select
 
Use the DateSerial() Function. See Help for more on this
function. In the example below replace xxDate with your
date field.

Dim xxDate as Date
xxDate = Now() 'or whatever date you choose

Select Case [account_class]
Case 1
[Last Audit Date] = DateSerial(Year(xxDate), _
Month(xxDate) + 36, Day(xxDate))
Case 2
[Last Audit Date] = DateSerial(Year(xxDate), _
Month(xxDate) + 24, Day(xxDate))
Case Else
End Select
 
Back
Top