How schooling affects cognitive skills is a fundamental question for studies of human capital and labor markets. While scores on cognitive ability tests are positively associated with schooling, it has proven difficult to ascertain whether this relationship is causal. Moreover, the effect of schooling is difficult to separate from the confounding factors of age at test date, relative age within a classroom, season of birth, and cohort effects. In this paper, we exploit conditionally random variation in the assigned test date for a battery of cognitive tests which almost all 18 year-old males were required to take in preparation for military service in Sweden. Both age at test date and number of days spent in school vary randomly across individuals after flexibly controlling for date of birth, parish, and expected graduation date (the three variables the military conditioned on when assigning test date). We find an extra 10 days of school instruction raises cognitive scores on crystallized intelligence tests (synonym and technical comprehension tests) by approximately one percent of a standard deviation, whereas extra nonschool days have almost no effect. The benefit of additional school days is homogeneous, with similar effect sizes based on past grades in school, parental education, and father's earnings. In contrast, test scores on fluid intelligence tests (spatial and logic tests) do not increase with additional days of schooling, but do increase modestly with age. These findings have important implications for questions about the malleability of cognitive skills in young adults, schooling models of signaling versus human capital, the interpretation of test scores in wage regressions, and policies related to the length of the school year.