You need to re-phrase your question, with a normal log. decay curve it will retain some magnetism virtually forever in practical terms. However if you ask 'how long will it take to lose 50% of its magnetism' (ie it's half life) then someone might be able to answer your question. It would depend on many factors as previously mentioned.
A magnet maintains its magnetisation better when the magnetic circuit is comleted. Store two bar magnets end to end or place a piece of steel along it to complete the circuit.