How soon do you need to patent an invention after it's been made?

As soon as possible or someone else will copy your invention and make the patent