Any tips on how to capture a full year age when converting from two years to a four year digit? Without asking for manual input?

The problem I think lands specifically for a 100 year age.

E.g. if we captured DDMMYY: 04/08/18 this person could be 100 years old eg 04/08/2018 or 04/08/1918. Is there any logic we can implement to manipulate this without asking for any user input?

  • It seems all you're left with is heuristics at that point. I'm afraid you won't be able to just magically guess correctly 100% of the time if you don't allow the user to disambiguate it themselves. Depending on your use case, this may or may not work: assume people aren't 100 years old (as that's very rare), and from this point on, allow the user to enter the full year. It's not much more work for the user, and it's actually more in line with how most people probably think of their birth year anyways (I think of my birth year as being 1991, not '91). Is collecting the full year not an option? Aug 8 '18 at 16:29

Jaroslav M's excellent answer gives the key idea: certain ranges of two-digit years are (almost exclusively) safe to extend to four digits; some are "probably 19xx"; some are "probably 20xx". I don't think you should aim for no manual input, but with that concept in mind you should be able to reduce it to a minimum.

Safe Case: 19...99 – Assume 19xx

For real users it is safe to assume that anyone with a recorded birth-year between 19 and 99 was born in the 20th century. The lower value, 19, must mean 1919 (despite the person now being 100) since we're still (at time of writing) in 2018. The upper value, 99, must mean 1999 (= 19 years old) since Emma Morano, the last person (known to be) born in 1899, died in 2017.

Fairly Safe Case: 00...09 – Assume 20xx

It should be fairly safe to assume that anyone with a recorded birth-year between 00 and 09 was born in the 21st century (and are therefore aged between 19 down to 10). Assuming 19xx would imply ages from 119 down to 109: the latter might be possible, but is very unlikely1.

Probably Safe Case: 10...18 – Assume 19xx

Unless you know you have records for children (as opposed to young users), then it fairly safe to assume that anyone with a recorded birth-year between 10 and 18 was born in the 20th century (and are therefore aged between 109 down to 101). Assuming 20xx would imply ages from 9 down to 1: unlikely for real users.

Verify the above

For all users you should probably display a notification (perhaps something like the Code of conduct that StackExchange is currently showing) along the lines of:

We're updating our records. Your recorded date-of-birth was dd/mm/yy which we've assumed means dd/mm/yyyy making you zz years old. Please [Click Here] if this is incorrect.

(Including the age is probably helpful, but you could remove it if you think some people might be sensitive to seeing it!)

Potentially Clarify

If you do have records for children (or users under 10), then for certain recorded birth-years (perhaps 05 to 15) you might consider explicitly asking the user to confirm whether to use 19xx (ages 114 down to 104) or 20xx (ages 14 down to 4).

Similarly, if you have historic records (i.e. of people who may have died), you may want to ask a similar question (although if that were the case, you really should have been using 4-digit years from the beginning).

1 This list of oldest living people shows the 100 oldest people and notes that there are estimated to be between 150 and 600 living people who have reach an age of 110. While that's an impressive number from a longevity point-of-view, the chances of any of them using your application is probably remote.

  • 1
    Unless they're high tech super-grannies. Aug 9 '18 at 12:32

is this already developed? Do you have data about how many users have the year of birth between '00 and '18? If you're capturing the DoB of your users, I would assume this is not very common, since your users would usually be at least 10-15 years old (unless it's a website for children), so you shouldn't have users with DoB 2008 - 2018... So such values might mean 1908 - 1918, but, again, not many people are 100-110 years old and use computers.

On the other hand, you may have users with DoB entered as '00 - '08, and there it's safe to assume that their DoB is 2000 - 2008, since it's more likely you have a 10-18 years old users than 110 - 118 years old...

If it's not developed yet, I would advise you to capture the full year as YYYY in order to get rid of the ambiguity. Also, format 04/08/18 is extremely ambiguous since it can be interpreted in at least three different ways depending on where you're from....

Sidenote: If you're dealing with medical records and capturing the DoB of patients, for example, then both small children and very old people may appear in the records, so this advice would not apply. But in such case it is even more important to capture the full year...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.