For some reason a lot of folks think it has to settle....also If you rebuy before 30 days...you don't actually lose the deduction....you just lose it for that year. The loss will carry over into the next year.......
Depends on the situation. If you are completing a short sale at a loss it is the settlement date. If completing a short sale at a gain than it's the trade date. For longs, it's the trade date, for losses and gains. Hope that clears up any confusion.