In real-world evidence (RWE), temporal shifts in clinical knowledge and practice need to be adjusted for treatment effect assessment. We use electronic health records (EHR) data to 1) assess the temporal trends in treatment decisions and patient outcomes; and 2) emulate a randomized controlled trial (RCT) using EHR with temporal trends properly adjusted. We emulated the COST Study Group Trial on open colectomy (OC) vs laparoscopy assisted colectomy (LAC) assessing using EHR data from Mass-General-Brigham. To address confounding in the emulation, we selected and adjusted for pretreatment variables. The temporal trends were adjusted by stratification of the calendar year when the surgeries were performed with co-training across strata. Total 943 met key RCT eligibility criteria. Various temporal trends were observed for which the test indicated significant evidence. The adjusted EHR emulation reached the same conclusion as the RCT: LAC is not inferior to OC in overall survival rate with risk difference (LAC vs. OC) at 5-year -0.007, 95% CI [-0.070,0.057]. The results were consistent for stratified analysis within each temporal period. The study demonstrates that confounding bias from temporal trends needs to be taken into consideration when conducting RWE studies with long time spans. With proper adjustment, RWE may supplement RCT in the assessment of treatment effect over time.