Click here to Skip to main content
15,905,558 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

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
You can use the DateTime.Addyears method to calculate the date 60 years ahead, then subtract 1 day.
 
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