The International Classification of Diseases , 10th Revision, Clinical Modification (ICD-10-CM) introduced diagnosis codes for week of gestation. Our objective was to assess the validity of these codes among live births, which could have major utility in perinatal research and quality improvement. We used linked birth certificate and patient discharge data from births in California during 2016-2019 (N = 1,843,992). We identified gestational age using Z3A.xx ICD-10-CM diagnosis codes in birthing patient discharge data and compared it with the gold standard of obstetric estimate, as recorded on the birth certificate. We further assessed sensitivity and specificity of gestational age categories (≥37 weeks, <37 weeks, <32 weeks, <28 weeks), given these categories are frequently of interest, and evaluated differences in validity of preterm birth (<37 weeks' gestation) by patient characteristics. One-million seven-hundred seventy-thousand one-hundred three patients had a gestational age recorded in patient discharge and birth certificate data. When comparing gestational age in patient discharge data with birth certificate data, the concordance correlation coefficient was 0.96 (95% confidence interval [CI] = 0.96, 0.96) and the mean difference between the two measurements was 0.047 weeks (95% CI = 0.046, 0.047 weeks). Ninety-five percent of the differences between the two measurements were between -1.00 week and +1.09 weeks. Sensitivity and specificity were 0.94 to 1.00 for all gestational age categories and were 0.94 to 1.00 for preterm birth across sociodemographic groups. We found week-specific gestational age at delivery ICD-10-CM diagnosis codes in patient discharge data to have high validity when compared with the best obstetric estimate on the birth certificate.