Can I go swimming with a Tampon?

Brianna
Friends asked me to go swimming, but I know I should be starting soon and most likely on the day we're going swimming. Never tried a tampon when swimming, usually stay out of the pool. Will it work, and if so for how long?