You can use a demo account for as long as you like - so long as you're actively trading. If you do not trade for two weeks (or one month for demo MT4 accounts), your account will be automatically closed.
MT5 demo accounts do not expire and remain active regardless of trading activity.