We consider a scale-invariant helical magnetic field generated during inflation. We show that, if the mean magnetic helicity density of such a field is measured, it can be used to determine a lower bound on the duration of inflation. Even if we just have upper bounds on the helicity, these can be used to derive constraints on the minimal duration if one assumes that the magnetic field generated during inflation is helical. Using three-dimensional simulations, we show that an initially scale-invariant field develops, which is similar both with and without magnetic helicity. In the fully helical case, however, the magnetic field appears to have a more pronounced folded structure.