It really varies. I never been close to a D student, but I happen to know a lot of people who are D students. It appears to me, that those D students that do become A students have a life style change. I'm not sure what causes a person to change so drastically, but I encourage it in these cases.
It requires more studying, less time going out, more self-motivation, less being told what to do, more asking questions, less talking in class, more deep thinking, less accepting of theorem at face value, and generally a lot more effert.
How long will it take? Who is to say. If you want an A in a class and you have a D, it really depends on how many test you are given. If you want to become a 'natural' A student, then it can take year(s) to accomplish these habits. Small successful steps are better than large clusmy leaps.