Hi
I tried Age calculator ...Only Displaying The Year ... I am getting exact the output of Months and Days ..I need Months Caluclation and Days Caluclation.
Please Send me Any one Help me ............
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Santosh UbalePosted Aug 7, 2014, 9:56 AM
This might help you
link: Calculate Age (Years + Months + Days) in C#
Thanks :)
"LIKE THIS ANSWER IF IT HELPS YOU" :)
Sandhiya PriyaPosted Oct 23, 2025, 4:04 AM
You’re trying to build an Age Calculator (in C# or JavaScript?), and right now it’s only showing years, but you also want months and days to be calculated accurately.
Let’s cover both cases — C# (backend) and JavaScript (frontend) — since many people do this in either.
Option 1: C# — Accurate Age in Years, Months, and Days
Here’s a clean method that gives exact years, months, and days between two dates:
Example Output
If today is 2025-10-23 and birthdate is 2000-05-10,
it will print:
Option 2: JavaScript (Web UI version)
If your age calculator runs in a web page:
Example Output
Explanation
We first subtract years, months, and days separately.
If
days < 0, it means the current day hasn’t reached the birth day yet in this month,so we borrow days from the previous month.
If
months < 0, it means the current month hasn’t reached the birth month,so we borrow one year and add 12 months.
Staff uniquewebdevelopersPosted Sep 22, 2025, 5:52 PM
You can calculate age in Years, Months, and Days by comparing the birth date with today’s date. The logic is:
Subtract the birth year from the current year for the years.
If today’s month is less than the birth month, subtract 1 year and adjust the months.
Do the same for days if today’s day is less than the birth day, borrow days from the previous month.
Example:
Birthdate:
2000-05-10Today:
2025-09-22Result → 25 Years, 4 Months, 12 Days
Most programming languages (like PHP, JavaScript, or Python) have built-in date functions to handle this calculation easily.
If you’d like to try it online, here’s a simple tool that does the calculation: Age Calculator