I'm not sure how long, but I went to test a theory of if it will save what you sold until you logged out, but when I checked my buyback tab, some of the things I sold yesterday where still there. I have also in the past been able to buy back things even though I switched zones.
I wouldn't use it as extra bank space, but it is quite helpful if your inventory is completely full and there is nothing you want to trash, but you need at least 3-4 spaces in your inventory to refine or deconstruct items, you can sell some things to make room and buy them back after.
When I started the game I used to sell all my stuff to woodworker in Davon's Watch. I'll check tonight whether he still has anything remaining of my crap...
"Do you want the book or not? Then go whack some people with Wabbajack!!"