We present an i-band photometric study of over 800 young stellar objects in the OB association Cep OB3b, which samples timescales from 1 minute to ten years. Using structure functions we show that on all timescales (tau) there is a monotonic decrease in variability from Class I to Class II through the transition disc (TD) systems to Class III, i.e. the more evolved systems are less variable. The Class Is show an approximately power-law increase (tau^0.8^) in variability from timescales of a few minutes to ten years. The Class II, TDs and Class III systems show a qualitatively different behaviour with most showing a power-law increase in variability to a timescale corresponding to the rotational period of the star, with little additional variability beyond that timescale. However, about a third of the Class IIs show lower overall variability, but their variability is still increasing at 10 years. This behaviour can be explained if all Class IIs have two primary components to their variability. The first is an underlying roughly power-law variability spectrum, which evidence from the infrared suggests is driven by accretion rate changes. The second component is an approximately sinusoidal and results from the rotation of the star. We suggest that the systems with dominant longer-timescale variability have a smaller rotational modulation either because they are seen at low inclinations or have more complex magnetic field geometries. We derive a new way of calculating structure functions for large simulated datasets (the "fast structure function"), based on fast Fourier transforms.