How long can I have swelling from a knee sprain?

Few days to weeks. Swelling usually subsides in 2 weeks but sometimes can take a little bit longer. If you have fluid (effusion) in the joint then it indicates internal damage to meniscus or cruciate ligaments.
Depends on injury. Swelling may last a long time following a an injury. An x-ray can show if there is an underlying fracture. You may have a soft tissue injury if it is just a sprain and may have damaged the muscle, tendon, or ligaments in the area. Have it evaluated by a professional and get the appropriate treatment.