Connecting Tech Pros Worldwide Help | Site Map

How to find date of retirement

Newbie
 
Join Date: Sep 2009
Posts: 3
#1: Sep 30 '09
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.
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 346
#2: Sep 30 '09

re: How to find date of retirement


Quote:

Originally Posted by karimufeed View Post

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.

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
Reply


Similar Visual Basic 4 / 5 / 6 bytes