By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,364 Members | 1,391 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,364 IT Pros & Developers. It's quick & easy.

How to find date of retirement

P: 4
I am working on an access project for pension calculation. I want to generate the retirement date automatically at the age of 60 years while filling the date of Birth. i.e. if the Date of birth is 15/1/1950 then the date of retirement will be 31/1/2010 and if the date of birth is 01/1/1950 then the date of retirement will be 31/12/2009 one day earlier.
Kindly help me how to generate the date of retirement by using VB code in an access project.
Sep 30 '09 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 636
@karimufeed
Hi

I feel sure that you have not given us all your requirements, but this does exactly what you have specified
Expand|Select|Wrap|Line Numbers
  1. Sub Test()
  2.     Dim DOB As Date
  3.     Dim RetirementDate As Date
  4.  
  5.     DOB = "15/01/1950"
  6.  
  7.     RetirementDate = DateSerial(Year(DOB - 1) + 60, Month(DOB - 1) + 1, 1) - 1
  8.  
  9.     MsgBox RetirementDate
  10.  
  11. End Sub
I am not sure what you want to happen with any other dates in the month/year !?

If you are not familiar with the DateSerial() function then I suggest you look at Help for more explanation, but all I can say is it is extremely flexible for calculating dates (more so than DateAdd() and DateDiff() IHMHO).

HTH


MTB
Sep 30 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.