I was only there for 3 days (long story), but I figure a week or two would probably be good, depending on what sort of activities you like. Pyramiden was great (although I would have loved to camp over there and explore it properly, instead of just the few hours we got during the day trip) but the boat ride over there from Longyearbyen takes like 3h, and we did this "walrus safari" thing where we got a private boat & guide who took us over to an island with a walrus colony, and we did some whale spotting (even saw a blue whale, holy crap).
It was summer when we went there (so at most a sweltering +10°C, apparently about as hot as it gets), but I think the next time I go over there I want to go during the winter (but after the sun's up, at first anyhow). Would love to do a looong ski trip (maybe even from coast to coast, but that'd be at least a few weeks' worth of skiing); that'll probably require glacier safety courses, but those might be doable there since they have a bazillion nature-oriented tour companies. There's probably snowboarding and downhill skiing to be had as well, but I'm more of a hiker / cross-country person so I don't really know. Generally if you're at all an outdoorsy type, you'll probably like it. Don't know how hiking in the summer would be, but my guess would be not too great since it seems like everything gets a bit muddy so it might be a bit of a slog (but this is based on very limited knowledge.)
One thing to keep in mind is that you really can't go anywhere outside Longyearbyen (the biggest settlement & "capital") without a guide, since you need someone with a rifle in your group due to polar bears (I'm not kidding.) You can try applying for a rifle permit if you know how to handle guns, but I don't know what the bureaucracy on that would be.