To express for how long you do/did/will do something in Spanish you do not need to use any prepositions.
Here are some examples:
However, the prepositions "durante" and "por" can also be used:
Bear in mind that durante is more frequently used than por.
Want to make sure your Spanish sounds confident? We’ll map your knowledge and give you free lessons to focus on your gaps and mistakes. Start your Brainmap today »