Calculate days between two dates
Calculate the number of days between two dates. Can be used for calculating the number of days since an important event, how many days alive, or to track the duration of a project.
Input dates
Share this tool
Frequently Asked Questions
Below you'll find answers to the questions we get asked the most. If your question isn't here, or you need more info, or have feedback, please get in touch.
How to calculate days between two dates?
Select two dates to see how many days have passed since that date. This will provide an accurate calculation because it using precise calculations. If the first date input is a future date compared the the second date input, it will show a negative number indicating days until that date.
When do you need to know how many days have passed?
Some examples include:
- Tracking the duration of a project or task.
- Calculating the age of a person or an object.
- Determining the number of days left until a deadline or event.
- Monitoring the time elapsed since a significant event. Think of a party, an anniversary or the last medical check-up.
- Calculating interest or penalties based on the number of days passed.
How can I calculate days passed myself?
To calculate days passed by hand, follow these steps:
- Note the current date and the selected date. Calculate the difference in years, months, and days separately.
- Convert the difference in years to days (considering leap years). There are 365 days in a year, except for leap years which have 366 days. Leap years are years that are divisible by 4, except for years that are divisible by 100 but not by 400. Last leap years were in 2024, 2020, 2016, 2012, 2008, 2004, 2000, 1996, 1992, 1988, 1984, 1980, 1976, 1972, 1968, 1964, 1960, 1956, 1952, 1948, 1944, 1940, 1936, 1932..
- Convert the difference in months to days (considering the number of days in each month).
- January has 31 days
- February has 28 days (but 29 days in a leap year)
- March has 31 days
- April has 30 days
- May has 31 days
- June has 30 days
- July has 31 days
- August has 31 days
- September has 30 days
- October has 31 days
- November has 30 days
- December has 31 days
- Add up all the days to get the total number of days passed.
In JavaScript, how to calculate days between two dates?
To calculate the days between two dates in JavaScript, you can use the following code:
const date1 = new Date('2024-01-01');
const date2 = new Date();
const timeDiff = date2 - date1;
const daysPassed = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
console.log(daysPassed);
In Python, how to calculate days between two dates?
To calculate the days between two dates in Python, you can use the following code:
import datetime
date1 = datetime.strptime('2024-01-01', '%Y-%m-%d')
date2 = datetime.now()
time_diff = date2 - date1
days_passed = time_diff.days
print(days_passed)
Related Calculation Tools
Roman numbers calculator
Convert numbers to roman numerals or the other way around. Enter a number and get the roman numeral version.
Intermitted Fasting Time Calculator
Calculate the hours when the intermittent fasting cycle ends with a simple fasting clock.
Pace to speed calculator - Min/km to Km/h
Convert running pace from minutes per kilometer to kilometers per hour and vice versa. Ideal for runners, marathoners, and athletes looking to track and improve their running speed.