• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reg age cal

 
vijay kumar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

How to caluculate a age if date of birth is in this format 01/12/1875


Regards,
Vijay.
 
Steve Fahlbusch
Bartender
Posts: 605
7
Mac OS X Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, don't know what it is you are requesting?

Are you asking:

a) If i have a date in mm/dd/yyyy format how do i contvert that to a date so i can calculate age?, or

b) What is the algorithm given a date to determine one's age?, and if so what is the format of the age (years old, years and days, years and months and days, ...hours? minutes? seconds?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at SimpleDateFormat. You can use that to parse a String into a Date object.

If you build Date objects for current time and birth date, you can work out the time between them with pretty simple math. Look at the doc for Date ... do you see a method that returns a number we might do math on? See if you can compute age in days or years. Avoid months - they're all different sizes which makes them mostly meaningless.

These are pretty vague hints ... I hope you have fun digging out the details yourself.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"if date of birth is in this format 01/12/1875"

So, is that January 12th, or 1 December? Using 01/12 as an example for date/month or month/day isn't very informative in an international context. Try 01/31 or 31/12.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic