Counting Days

Aulia Ichsan Rifkyano
2 min readOct 18, 2020

Counting day from one date to another is not difficult. I use few steps to count one date to another.

Take two dates; let’s say 1/2/2019 and 30/11/2020. Then see if those years are leap years or not. Prepare the number of each day in each month of each of those dates. So the first date is not in a leap year, but the second one is in leap year.

For the earlier date, count how many days until the last day of December. To do so, count how many days until the end of the month. In our example, it takes 28–2=26 days to get till the end of February. Then count how many days it takes from the first day of the next month, which is March, until the end of December. It takes 306 days to get from March to the end of December in a non leap year(2019).

For the later date, count how many days it takes from the first of January until the date. It is similar to the previous method. You count from the first of January until the end of the previous month from the date. So if our date is 30/11/2020, it takes 305 days from first of January till the end of October. Then you add the day from the date, which is 30. So it takes 305 + 30 = 335 days from the first of January till the oncoming day.

After that it’s just simple addition. Now we know that it takes 306 + 335 = 641 days from 1/2/2019 until 30/11/2020.

It’s just one of the method I use that I think is simple enough for people to understand. If you have a better algorithm or method please let me know.

Have a nice day.

Counting Days
Day 128

--

--