About a month, but can take a week longer if you aren't careful.
The mortgage is the only factor in this equation, everything else will be shorter. During the option period, which is your time to bail out of the contract before execution, you can schedule everything that needs to be done: inspection, bank appraisal, offer adjustments (from appraisal) and survey. Inspectors work by contact, you can sometimes get them there the same day as the offer acceptance. There's tons of inspection companies, they'll meet about any deadline. The bank appraiser is on the bank schedule, they'll work within your option period, usually 1-3 days. Many don't even appraise in person for new builds or recent appraisals. The survey isn't always necessary, depending on the last survey, but it's just like the appraiser, they'll work your timeline.
The mortgage is a different story. Pre approval takes 1-2 days, if you don't already have deep A+ credit. Terms and financial approval start after you tell them you're in contract, often the real estate agents will do this, but call them yourself. Your full credit report, which is the risk analysis performed by the bank, takes 3-5 days, depending on how big of a hurry they're in. This time is also used to get all the survey and proof of income and tax documents. To move the process along, you need to keep on your broker, the first part of the timeline is dependent on their due diligence. Then the loan moves to underwriting. This process is slow and your broker cannot speed it up. The underwriters have to do extensive verification, reporting, risk validation, balance an asset pool with your mortgage and many others. This takes 2-3 weeks. I have heard of deals falling apart because underwriting took too long. I've been told this happens for a variety of reasons, including imbalanced asset classes, large volume, a documentation error and "oops". After the broker gets it back, funding takes about a day after final signing.
Signing things happens in hours, but you have a separate meeting with the title and mortgage company, but this will all happen within your closing date. The agents probably know most lenders well enough to determine if your timeline will be a little different.
Also, you and the seller determine the closing date, so if you're planning this because of a move out time, you can certainly start early, but cannot start late.