DEV Community

Ashley Chen
Ashley Chen

Posted on

Generation Boundaries in Code: Why 1996 and 1997 Fall on Opposite Sides

"Millennial" sounds like a fuzzy label, but any program that assigns one has to make it a hard interval. The moment you encode it, two questions appear: which authority defines the cutoffs, and what happens at a birthday exactly on the boundary.

One definition, expressed as cutoffs

The Pew Research Center's widely used ranges put Millennials at 1981–1996 and Gen Z at 1997–2012. The rest of the ladder: Gen X 1965–1980, Boomers 1946–1964, the Silent generation 1928–1945. A table of half-open intervals [start, end) removes the ambiguity at the joins:

const COHORTS = [
  [1928, 1946, 'Silent'],
  [1946, 1965, 'Baby Boomer'],
  [1965, 1981, 'Gen X'],
  [1981, 1997, 'Millennial'],
  [1997, 2013, 'Gen Z'],
];

function cohort(year) {
  const row = COHORTS.find(([lo, hi]) => year >= lo && year < hi);
  return row ? row[2] : 'outside defined range';
}
Enter fullscreen mode Exit fullscreen mode

1996 -> Millennial, 1997 -> Gen Z. With an inclusive upper bound (year <= 1997) both would be Millennial — which is why the end year is stored as the next cohort's start.

Worked example: the edge years

Birth year Interval matched Result
1980 [1965, 1981) Gen X
1981 [1981, 1997) Millennial
1996 [1981, 1997) Millennial
1997 [1997, 2013) Gen Z

Notice that 1980 and 1996 are the last year of their cohorts, not the first year of the next one. That is a deliberate consequence of the half-open convention, not a bug.

The part that isn't arithmetic

There is no ISO standard for generation boundaries. Pew's ranges differ from the U.S. Census Bureau's and from Strauss–Howe's generational theory. A program that presents one mapping as the answer is making an editorial choice, so expose the source with the result:

function cohortWithSource(year) {
  return { year, name: cohort(year), scheme: 'Pew Research Center (2023)' };
}
Enter fullscreen mode Exit fullscreen mode

If your data is a full date rather than a year, decide explicitly whether someone born 31 December 1996 and someone born 1 January 1997 belong to different cohorts. Most published cutoffs are year-based, so the honest implementation truncates to the calendar year and says so.

For trying other birth years and seeing the boundary behaviour directly, see the generation calculator.

Related reading

Top comments (0)