The objective of this study was to determine the effects of age, sex, and type of surgery on postoperative pain trajectories derived in a clinical setting from pain assessments in the first 24 hours after surgery. This study is a retrospective cohort study using a large electronic medical records system to collect and analyze surgical case data. The sample population included adult patients undergoing nonambulatory nonobstetric surgery in a single institution over a 1-year period. Analyses of postoperative pain trajectories were performed using a linear mixed-effects model. Pain score observations (91,708) from 7293 patients were included in the statistical analysis. On average, the pain score decreased about 0.042 (95% confidence interval [CI]: -0.044 to -0.040) points on the numerical rating scale (NRS) per hour after surgery for the first 24 postoperative hours. The pain score reported by male patients was approximately 0.27 (95% CI: -0.380 to -0.168) NRS points lower than that reported by females. Pain scores significantly decreased over time in all age groups, with a slightly more rapid decrease for younger patients. Pain trajectories differed by anatomic location of surgery, ranging from -0.054 (95% CI: -0.062 to -0.046) NRS units per hour for integumentary and nervous surgery to -0.104 (95% CI: -0.110 to -0.098) NRS units per hour for digestive surgery, and a positive trajectory (0.02 [95% CI: 0.016 to 0.024] NRS units per hour) for musculoskeletal surgery. Our data support the important role of time after surgery in considering the influence of biopsychosocial and clinical factors on acute postoperative pain.