The sooner you need the money, the less risk you will be willing to take on.
If you have until you retire, you may be more willing to gamble on riskier investments for the potential of bigger returns because if it doesn't work out you will still have plenty of time to make up the loss. However, if you need the money sooner for a car you should only take on a minimal amount of risk.