You can usually replace “within” with “in” to streamline your writing. “The change almost always improves a sentence,” as Bruce Ross-Larson says in Edit Yourself: A manual for everyone who works with words.
However, there are exceptions. For example, as Michael Strumpf and Auriel Douglas say in The Grammar Bible:
An event that will take place in an hour will occur will occur at the end of sixty minutes. An event that will take place within an hour may occur any time between the present and sixty minutes from the present.
Ross-Larson describes when you must favor “within”:
Within should be used when the object of the preposition is an area or space—and as a synonym for inside of, as in limits.