Based on the Rayleigh diffraction integral, an analytical expression for the spectrum of polychromatic Gaussian beams diffracted at an aperture is derived, and the paraxial results are treated as a special case of our general expression. The main attention is focused on the effect of ratio of the waist width to the central wavelength w0/λ0 and truncation parameter δ on spectral shift and spectral switching. Only when w0/λ0 and δ satisfy certain conditions are the paraxial approximation results consistent with the nonparaxial ones. The nonparaxiality of field results in different spectral shifts and changes of the critical position where the spectral switching takes place.