We evaluated the impact of preoperative SARS-CoV-2 infections on postoperative outcomes among patients undergoing elective cancer surgery. This ambidirectional (retrospective and prospective) study was conducted among patients undergoing elective cancer surgery between December 2022 and March 2023. Patients with different time intervals between SARS-CoV-2 infection and surgery (0-6 weeks and ≥7 weeks) were compared with those without SARS-CoV-2 infection. The primary outcome was 30-day postoperative pulmonary complications (PPCs). Secondary outcomes included 30-day postoperative mortality, major adverse cardiovascular events (MACE), and other postoperative adverse outcomes. Of the 830 patients analyzed, 239 (28.8%) had SARS-CoV-2 infection 0-6 weeks before cancer surgery, and they had a higher incidence of PPCs (4.6% in no SARS-CoV-2 infection, 12.1% in 0-6 weeks, and 5.1% in ≥7 weeks, p = 0.001). The logistic regression model revealed that, compared with patients without SARS-CoV-2 infection, surgery performed 0-6 weeks after SARSCoV-2 infection was associated with a higher risk of PPCs (adjusted odds ratio [aOR] 2.83; 95% confidence interval [CI] 1.34-5.98), and surgery performed ≥7 weeks after SARSCoV-2 infection was associated with a similar risk of PPCs (aOR 1.19; 95% CI 0.54-2.64). However, preoperative SARS-CoV-2 infection was not associated with a risk of 30-day postoperative mortality, MACE, or other adverse postoperative outcomes. In patients with preoperative Omicron variant infection, nonemergency cancer surgery can be scheduled ≥7 weeks after the infection to decrease the risk of PPCs, but it can be advanced if the risk of delay exceeds the risk of proceeding with the surgery.