+ 3
How to get the age of a person from his date of birth
I working in a project that requires me to generate the age of person (in years months and days)
17 Respuestas
+ 1
The module is clever, its been written to have complete knowledge of leap years etc. You need to use the python documentation, find the module in it, and it explains the functions in the module, what they do and how they work.
If your code works though, great. But I cant tell from the example if its aware of the varying days per month etc.
+ 8
... and what programming language is it about?
+ 3
Same question is here check this.
https://stackoverflow.com/questions/2217488/age-from-birthdate-in-JUMP_LINK__&&__python__&&__JUMP_LINK
+ 2
What have you done so far?
+ 1
Sorry i forgot to mention that
+ 1
I asked my math teacher and we both worked( like 5 minutes ) to find the answer and we found a good way
+ 1
Now day = number of day we are in
Days = the number of day in date of birth
Age days = the number of day the human lived
------------------------------------
If days <now day :
Age days = (Days + number of days in that month ) - now
days
Months - 1
Else
Age days = now day - days
----------------------------------------------
And the samething in months and years
+ 1
https://docs.python.org/3.6/tutorial/
Heres a link to the documentation generally, started with the tutorial so you know it exists. Just use the search bar at the top of the page to find the datetime module. Bookmark this site its the official manual. Use it often.
+ 1
A good trick I use is finding the difference between millis between B day and today and convert it to any date format. This way is more accurate and very easy
+ 1
Seniru Pasan That is an interesting idea. Do you have an example of that? I looked through your list of codes and didn't spot one.
0
It is python
0
And I wanted to create a program that calculates the age of person in years,months and day . i have created the gui using tkinter already but the problem was how to convert that dob (date of birth) in three varibles (years , months , days) and thanks for responding
0
Dont try and do it all by yourself, use the datetime module and save yourself a headache
0
I still a beginner i started learning python a week ago , so i couldn't know what func to use from the datetime library there seems to be a lot of ways to do this but want a mathematical way , cause the leap years will confuse the module as bad as the difference in number of days in a month will do
0
Thanks for answer , I haven't tested my code yet. But it look like using the module is easier , thank you I didn't know about the documentation on the web . can you please give a link to that documentation
. and thank you for your support
0
Thank you for that , see you on another question
0
Thank you for that , see you on another question