How long does it take to buy a house if you’re getting a loan? Weeks, months, years?

So confused how long is the process of buying a house for the first time? Is it weeks, months, years.