With some medications, erections can happen anytime within 4 or 5 hours of taking the pill. This does not mean that the erection will last for 4 or 5 hours. It means that an erection can happen anytime during that time period. Other medications work for up to 36 hours.