In the era of large high-resolution spectroscopic surveys, high-quality spectra can contribute to our understanding of the Galactic chemical evolution, providing chemical abundances belonging to the different nucleosynthesis channels, and also providing constraints to stellar age. Some abundance ratios have been proven to be excellent indicators of stellar ages. We aim at providing an empirical relationship between stellar ages and [C/N] using, as calibrators, open star clusters observed by both the Gaia-ESO and APOGEE surveys. We use stellar parameters and abundances from the Gaia-ESO and APOGEE of the Galactic field and open cluster stars. Ages of star clusters are retrieved from the literature sources and validated using a common set of isochrones. We use the same isochrones to determine, for each age and metallicity, the surface gravity at which the first dredge-up and red giant branch bump occur. We study the effect of extra-mixing processes in our sample of giant stars, and we derive the mean [C/N] in evolved stars, including only stars without evidence of extra-mixing. Combining the Gaia-ESO and APOGEE samples of open clusters, we derive a linear relationship between [C/N] and logarithmic cluster ages. We apply our relationship to selected giant field stars in both Gaia-ESO and APOGEE. We find an age separation between thin and thick disc stars and age trends within their populations, with an increasing age towards lower metallicity populations. With such empirical relationship, we are able to provide an age estimate for giant stars in which C and N abundances are measured. Isochrone fitting is less sensitive for giant than dwarf stars at the turn off. The present method can be thus considered as an additional tool to give an independent estimate of the age of giant stars, with uncertainties in their ages comparable to those obtained using isochrone fitting for dwarf stars.