Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sub Test()
Dim DOB As Date
Dim RetirementDate As Date

DOB = 15/01/1950

RetirementDate = DateSerial(Year(DOB - 1) + 60, Month(DOB - 1) + 1, 1) - 1

MsgBox RetirementDate

End Sub
Posted
Comments
Sibasisjena 9-Jan-14 6:11am    
You can not subtract integer from datetime.

//The follow is not allowed.
DOB - 1

1 solution

You may try to replace
Quote:
RetirementDate = DateSerial(Year(DOB - 1) + 60, Month(DOB - 1) + 1, 1) - 1

with
VB
DOB = DOB.AddDays(-1)
RetirementDate = DateSerial(DOB.Year + 60, DOBM.Month + 1, 1) - 1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900