How to calculate ages based on the slected date?

  • Thread starter Thread starter Showjumper
  • Start date Start date
S

Showjumper

I am working on an app that lets users pick dates via a calendar control. I
hen need to calculate the age and show it in a form such as 1 year 2 months
1wk. Its for a veterinary practice so i need to be able to show the number
of weeks if its less than month and the nunber of months also. Any tips or
ideas is appreciated. I am using vbnet.


Ashok
 
Store the date from the calendar as a DateTime type and calculate the
difference using .subtract:

Dim pickedDate as DateTime = date from calendar
Dim age as DateTime = now.subtract(pickedDate)

You can now do whatever calculations on "age" that you need to.
 
Back
Top