How long after you were convicted can you have a gun?

After you have received a pardon and are no longer a convicted felon.

Answer

It depends entirely upon the state you live in, and the violation you were convicted of. Most states do not ban gun ownership by those convicted of misdemeanors, only those guilty of a felony. Even if convicted of a felony, there is usually a process by which the former felon can get their gun rights re-instated, though it may involve a considerable amount of time and paperwork.