A spectral survey in the 1 mm wavelength range was undertaken in the long-period comets C/2012 F6 (Lemmon) and C/2013 R1 (Lovejoy) using the 30 m telescope of the Institut de radioastronomie millimétrique (IRAM) in April and November−December 2013. We report the detection of ethylene glycol (CH2OH)2 (aGg’ conformer) and formamide (NH2CHO) in the two comets. The abundances relative to water of ethylene glycol and formamide are 0.2–0.3% and 0.02% in the two comets, similar to the values measured in comet C/1995 O1 (Hale-Bopp). We also report the detection of HCOOH and CH3CHO in comet C/2013 R1 (Lovejoy), and a search for other complex species (methyl formate, gl...