This is a more complex question than it may seem at first, but I will try to explain my answer in some detail. To begin with, your inability to work must be due to medical problems, whether physical or mental. In other words, no matter how long you are out of work, you cannot get disability unless your inability to work is caused by medical conditions.
Assuming your inability to work is due to medical problems, federal law identifies the time period necessary to claim disability. Under the Social Security Act in order to be considered disabled, you must have been out of work or be expected to be out of work due to medical problems for at least one year. That means if you have already been out of work for one year as a result of medical conditions, you would be eligible.
However, it is the second part of this definition which is the most important. Specifically, if you are expected to be unable to work for at least one year due to your medical conditions, then you are eligible immediately even if you have not been out of work for one day on the date you apply.
A lot of people call my office indicating that they want to apply for disability due to medical problems. They describe their medical conditions and explain how awful they are. I then ask how long they have been out of work. They say they still work full time. At that point I tell them they have no case at all. Before you can claim disability (an inability to work), you must generally not be working in any significant capacity. If you are still working then you cannot claim that you are unable to work. Again, you must have been out of work or be expected to be out of work for at least one year before you apply.
The toughest scenarios are when someone has been seriously injured but it is not entirely clear whether they will be out of work for a full year. My recommendation in that instance is always to apply and see what happens later. If you apply and later return to work before a year is up, then you can just drop your application at that time. If you end up not being able to work for a year or longer, then you will be glad that you got the process started already. If you are over 50 years of age, I would always recommend being on the safe side and applying for benefits as soon as possible.