Generally you have to be self employed for a minimum of 6-months but banks often will require 2-years before they can approve a mortgage.
There are exceptions and it often depends on the type of work you are engaged in. If you are a person that is contracting to a single company then you may be treated more like an employee.
It’s important to ensure that the application for finance is prepared to answer the lenders questions and give yourself the best chance of success. That is why most self employed will look to work with an adviser that knows what the banks and lenders need.