How soon after masturbating can I get good erection to have sex? Or it doesn't have a time period??

Probably 30 minutes. Possibly less. No fixed time period & also depends upon how excited you get. In fact a healthy young male can usually achieve multiple ejulations & even more erections, sufficiently rigid for sexual penetration, every day. Enjoy.
No time period. For a young, healthy male, you may be able to achieve erections one to several times a day. It makes no difference if the erections are from self-stimulation or from the help of a partner. Hard is hard...