Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on an mysql project in vb.net . 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
Posted
Updated 7-Jan-14 20:47pm
v2

You can use the DateTime.Addyears method to calculate the date 60 years ahead, then subtract 1 day.
 
Share this answer
 
vba code

Function RetiringDate(DOB As Date) As Date
Dim dob_day, dob_mnth, dob_yr, ret_day, ret_mnth, ret_yr As Long

dob_day = Day(DOB)
dob_mnth = Month(DOB)
dob_yr = Year(DOB)

If dob_day = 1 And dob_mnth = 1 Then
ret_mnth = 12
ret_yr = (dob_yr + 60) - 1
ElseIf dob_day = 1 Then
ret_mnth = dob_mnth - 1
ret_yr = (dob_yr + 60)
Else
ret_mnth = dob_mnth
ret_yr = (dob_yr + 60)
End If

If ret_mnth = 1 Or ret_mnth = 3 Or ret_mnth = 5 Or ret_mnth = 7 Or _
ret_mnth = 8 Or ret_mnth = 10 Or ret_mnth = 12 Then
ret_day = 31
ElseIf ret_mnth <> 2 Then
ret_day = 30
Else
ret_day = 28
End If

RetiringDate = CDate(ret_yr & "/" & ret_mnth & "/" & ret_day)
End Function
 
Share this answer
 
Comments
CHill60 16-Mar-15 4:22am    
Question is over a year old, answered and tagged VB.NET not VBA
Kissu Pandey 13-Sep-23 8:41am    
Thanks sir,,🥰🥰🥰🥰😍😚😙😗😗😃😄😘😆🥰😂🤣😭😅😁😃😰😨😨😦😮😲😳🙁🙄😥😞🤗🤗😬😬😐😶🤐🤐🤫🤭🤭😠😠☹️😥😥😟😞😱🤨🤨🧐😒🙄🙄😤🤫😠😤😤😤🤐😒😐😑😱🤬😰😰😨😧😦😮😲😳🤯😕😡🥱🤭🙄🧐🤨🤓🤑😇🤥🤕🤒🤧😎😎🤡😈👿👻🎃💩👺🔥💯💫🌟💥💨😺🙉🙈🕳️💤💦💦💛💚💙💜🤎🖤🤍💘❣️♥️💌💓💗💖💔💔💋🫂👥👤👣🧠🫀👏👍👎🙌👐🤲🤝🤜🤛✊👊👋🤚🖐️✋🖖🤟🤘
Kissu Pandey 13-Sep-23 9:44am    
How to make a software in vb.net
CHill60 13-Sep-23 9:52am    
Buy a book

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