Based on a unique dataset comprising all 325,000 Austrian patients that were under pharmaceutical treatment for diabetes during 2006 and 2007, we measured the excess risk of developing diabetes triggered by undernourishment in early life. We studied the percentage of all diabetes patients in the total population specifically for each year of birth, from 1917 to 2007. We found a massive excess risk of diabetes in people born during the times of the three major famines and immediately after, which occurred in Austria in the 20th century: 1918-1919, 1938, and 1946-1947. Depending on the region, there was an up to 40% higher chance of having diabetes when born in 1919-1921, compared with 1918 or 1922, where age-specific typical diabetes ratios are observed. The excess risk for diabetes was practically absent in those provinces of Austria that were less affected by the famines. We show that diabetes rates exhibit nontrivial, age-specific sex differences, and correlate with the economic wealth of the region. Our results might be of relevance for establishing higher awareness in the health system for those born in high-risk years, and underline the importance of ensuring sufficient nutrition in prenatal and early stages of life.