Aims. We seek is to identify old and massive galaxies at 0.5<z<2.1 on the basis of the magnesium index MgUV and then study their physical properties. We computed the MgUV index based on the best spectral fitting template of $sim$3700 galaxies using data from the VLT VIMOS Deep Survey (VVDS) and VIMOS Ultra Deep Survey (VUDS) galaxy redshift surveys. Based on galaxies with the largest signal to noise and the best fit spectra we selected 103 objects with the highest spectral MgUV signature. We performed an independent fit of the photometric data of these galaxies and computed their stellar masses, star formation rates, extinction by dust and age, and we related these quantities to the MgUV index. We find that the MgUV index is a suitable tracer of early-type galaxies at an advanced stage of evolution. Selecting galaxies with the highest MgUV index allows us to choose the most massive, passive, and oldest galaxies at any epoch. The formation epoch t_f computed from the fitted age as a function of the total mass in stars supports the downsizing formation paradigm in which galaxies with the highest mass formed most of their stars at an earlier epoch.