Depends on the type of string, some will lose tension faster than others. If you are a casual player it doesn't really matter, just re-string when it breaks. But obviously if you see signs of wear, you'll want to have a back-up or just cut and re-string. The worst is to have it break during play and no backup
I agree with what Chan1011 posted above. If you're just a casual player (i.e. not serious) then just play till it breaks. But IF you are serious about your game, then I would say about 1 month or 3 months max.
I think the original poster meant : "Is it good to have the string lay around for 2-3 years before I use them to string my racket."
Oh! Now I get it. Depends on the conditions I suppose. If it's been in a dark, fairly constant-temperature cupboard then definitely still useable. But if it's been exposed to the elements then maybe not. I generally do not have strings that lay around for 2-3 years though so I've never tried.
I've had good results with old strings still in their packaging - a coworker gave me a set of BG66 strings he found in his garage.... my guess is they're about 20 years old. Strung it up on my trusty ol MP100. They lasted about 2 months - play about 6 hours per week - before they broke. (above average for a BG66) The other set was a pack of BG 80s which I had lying around for the better part of 5 years because of the break i took from badminton during my university years - they lasted quite a while before they broke.... I believe if they are stored in non-hostile conditions, they'll be perfectly fine.
i live in california USA and it's very dry here compared to asia, so if i leave strings on my racket that long, they will get really dry, so i usually have a backup just in case it snaps. i tend to play till it breaks or when i'm tired of the string's feel/color.
Not sure about 2-3 years, but it just depends on the storage conditions. I keep my strings in original packaging, some in ziplocs, and on top of that in a box stored in a cool, dark, dry place that gets no natural light at all (storage room).
I've had the same strings (purple BG65) on my Carbonex 8SP for about 20 years now and they are still in useable condition, albeit they're only at 18lb tension or so... LOL