Within means inside the limits of something — within an hour, within the law, within walking distance, within the building.
It is used far more of limits than of physical enclosure, and that is the useful distinction from inside: inside the box is physical, within budget is a limit. With time it means before the end of a period: within a week means at some point in the next seven days, which is not the same as in a week, meaning seven days from now. That difference matters in contracts and in arrangements, and getting it wrong changes a deadline. Within is formal; from within is the standard phrase for change coming from inside an organisation.
1prepositionperiodInside the limits of a period of time.
“You will get a reply within three working days.”
2prepositionamountInside the limits of an amount or a rule.
“The project came in within budget.”
3prepositionwithinInside a place or an organisation.
“There is disagreement within the party.”
Too few real examples of this word to estimate which sense is commonest.
within is a position inside limits.
Old English
wiþinnan
Middle English
withinne
English, today
within
From Middle English withinne, withinnen, from Old English wiþinnan; equivalent to with + in.
Etymology from Wiktionary, CC BY-SA