The normalized excess variance is a popular method used by many authors to estimate the variability of active galactic nuclei (AGNs), especially in the X-ray band. We show that this estimator is affected by the cosmological time dilation, so that it should be appropriately corrected when applied to AGN samples distributed in wide redshift intervals. We propose a formula to modify this estimator, based on the use of the structure function. To verify the presence of the cosmological effect and the reliability of the proposed correction, we use data extracted from the XMM-Newton Serendipitous Source Catalogue, data release 5 (XMMSSC-DR5), and cross-matched with the Sloan Digital Sky Survey quasar catalogue, of data release 7 and 12.