It differs by state and by the mortgage company that holds the loan and a lot of other things. Are you looking to buy a home that is being foreclosed on, or are you looking at forestalling being foreclosed on? I've seen some short sales drag on for months until the home went into foreclosure (with several good contracts over the list price sitting on the table), then the bank had to process the home through their system and put it back on the market as a foreclosure, and I"ve seen others go quickly. I've seen some banks once they foreclosed on a home, get it turned and on the market quickly, I've seen others that had it languish in their system for months before they got it on the market and someone was able to purchase it, so a lot of the answer to your question really depends on the full question and a lot of other details
what is the status of the home - are the payments currently being made or not? if not, are they being partially made or not at all?
who is the lender and HOW MANY lenders are involved (that includes home equity loans as well as second and third mortgages - any loan or lien against the home has to be accounted for, not just the main mortgage. taxes, etc have to be taken into consideration also - a second mortgage holder can hold up foreclosure procedures while they work out what they will get out of the deal for months
is the current owner cooperating with the bank, do they want to walk away or have they walked away or are they refusing to communicate with the bank?
Is the home on the market or not, if it is, is it in good condition and priced correctly for condition, price and location or is it overpriced?
Has the bank agreed to a short sale or a foreclosure sale?
Who legally owns the property at this point - the bank or the home owner?
Keep in mind that buying a foreclosure does not mean that you always get a clear title, often the buyer has to pay off any other liens (taxes, mechanics liens etc that are on the home.
Does the home owner have anyone helping them with the paperwork and details as they go through the process or not (there are specialist who do that (the banks pay them), if not , it typically takes much longer since the general consumer typically has no idea who to call and what questions to ask.