Windowing problem

[…] you may […] be stuck with data containing two-digit year fields. You have tried to get it expanded to four digits at the source, but it simply cannot be done.

In this case, you need to adopt a technique called “windowing”. Windowing means taking the two-digit year and applying common sense to determine the century that it belongs in.

Obviously, windowing cannot be used for data that might span a period greater than 100 years. For instance, the birth years of people in the general population. There have always been a number of people living beyond the age of 100, and as health care improves that number can only increase. If you code a birth year as “96”, that could be either 1996, which would indicate a two-year-old, or 1896, which could indicate a 102-year-old. For a short time after the year 2000, there will be people alive who were born in three different centuries!

Source: https://www.uic.edu/depts/accc/software/isodates/fixing.html

Java Strategy

For parsing with the abbreviated year pattern (“y” or “yy”), SimpleDateFormat must interpret the abbreviated year relative to some century. It does this by adjusting dates to be within 80 years before and 20 years after the time the […] instance is created.

Source: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

Reference YearInputs
‘95’‘74’‘50’‘34’‘26’‘18’‘2’
20341995197420502034202620182002
20151995197419502034202620182002
19971995197419501934192619182002
19861995197419501934192619182002

Posix Strategy

When a century is not otherwise specified, values in the range [69,99] shall refer to years 1969 to 1999 inclusive, and values in the range [00,68] shall refer to years 2000 to 2068 inclusive […].

Source: https://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html

Reference YearInputs
‘95’‘74’‘50’‘34’‘26’‘18’‘2’
20341995197420502034202620182002
20151995197420502034202620182002
19971995197420502034202620182002
19861995197420502034202620182002

Office Strategy

If you enter a date with a two-digit year in a text formatted cell or as a text argument in a function […] Excel interprets the year as follows:

Source: https://docs.microsoft.com/en-us/office/troubleshoot/excel/two-digit-year-numbers

Reference YearInputs
‘95’‘74’‘50’‘34’‘26’‘18’‘2’
20341995197419501934202620182002
20151995197419501934202620182002
19971995197419501934202620182002
19861995197419501934202620182002

MySQL Strategy

Date values with 2-digit years are ambiguous because the century is unknown. Such values must be interpreted into 4-digit form because MySQL stores years internally using 4 digits.

For DATETIME, DATE, and TIMESTAMP types, MySQL interprets dates specified with ambiguous year values using these rules:

Source: https://dev.mysql.com/doc/refman/5.7/en/two-digit-years.html

Reference YearInputs
‘95’‘74’‘50’‘34’‘26’‘18’‘2’
20341995197420502034202620182002
20151995197420502034202620182002
19971995197420502034202620182002
19861995197420502034202620182002

IBM I Strategy

If a 2-digit year is moved to a 4-digit year, the century (1st 2 digits of the year) are chosen as follows:

Source: https://www.ibm.com/docs/en/i/7.2?topic=mcdtdi-conversion-2-digit-years-4-digit-years-centuries

Reference YearInputs
‘95’‘74’‘50’‘34’‘26’‘18’‘2’
20341995197419502034202620182002
20151995197419502034202620182002
19971995197419502034202620182002
19861995197419502034202620182002

My Strategy

2-digit dates are ambiguous on the century. It is interpreted accordingly to the provided reference year as follows:

Source: Lautaro Emanuel

Reference YearInputs
‘95’‘74’‘50’‘34’‘26’‘18’‘2’
20341995197419502034202620182002
20151995197419501934192619182002
19971995197419501934192619181902
19861895197419501934192619181902

The code for all these strategies can be found here

Other strategies: