# ISO 8601 and computing differences between dates

This brief article describes how to compute differences between dates manually using ISO 8601 and suggests that it may be easier to remember dates in ISO 8601 format.

## ISO 8601

editISO 8601 is an international standard for dates and times. For example, 01/02/03: Is that January 2, 2003, or 1 February 2003 or 2001 - January 3? You can't tell by looking, and each of these three alternative interpretations is used someplace in the world. The first two are both used in the US, so it's not easy to tell which interpretation is intended unless one of the three numbers is greater than 12.

ISO 8601 solves this problem by insisting we write YYYY-MM-DD. Thus, Christmas Day 2003 for most people in the West is 2003-12-25 in ISO 8601 format. Similarly, Valentine's Day 2001 is 2001-02-14.

What's the time difference between Valentine's Day 2001 and Christmas 2003? Easy:

- (2003-12-25) - (2001-02-14) = (2-10-11) = 2 years, 10 months, and 11 days.

Computing the difference between Christmas 2001 and Valentines 2003 is harder but not too hard:

- (2003-02-14) - (2001-12-25)

We can't subtract 25 from 14 and get a positive number, but we can think of February 14 as the 45th day of January, so 2003-02-14 is the same as 2003-01-45. With this equivalence, we can subtract 25 from 45 and get a difference of 20 days.

Similarly, we can't subtract 12 from 1 and get a positive number. However, again, we can think of January 2003 as the 13th month of 2002. With this, we rewrite 2003-02-14 as 2003-01-45 and then as 2002-13-45. Now we can subtract as follows:

- (2002-13-45) - (2001-12-25) = (1-01-20) = one year plus 1 month and 20 days.

Oh, that was almost hard ;-)

## Roman numerals

editHave you ever tried to do arithmetic with Roman numerals? It's much easier with so-called Arabic numerals, which seem to have been invented in India and brought to Europe by Arab traders.

At least for the present author it's much easier to do arithmetic with dates in ISO 8601 format than in other formats. Moreover, it seems easier to remember dates in ISO 8601 format, perhaps because it's easier for me to remember the number for each month than the name; it's certainly more obvious that June comes after March, etc.