How long it takes to get a literary agent has a lot to do with your querying strategy and will be impacted by your book genre. The faster you query lots of book agents, the faster you'll be able to get a book agent. However, there are guidelines regarding how many publishing agents you should query at once. For some book categories, you can query hundreds or many hundreds of publishing agents. However, if you've written a collection of short stories or poetry, you'll find there are very few author representatives who represent those types of books. The more book agents there are who represent your type of book, the longer it will take you to query them all. Let's hope, of course, you won't need to query them all. But, if you do--and you're willing to do to the work--it will obviously take more time to query hundreds or many hundreds of author representatives than two dozen.
In addition, some of the literary agencies you query will have more than one literary agent you can query. Remember, literary agencies don't let authors submit their work to multiple publishing agents at one agency at the same time.
If you get a rejection letter from a book agent at a literary agency with multiple book agents, you can--and should--query the next book agent there who represents your type of book when you get a rejection. The same thing applies if it's been two months since you queried an author representative at the literary agency and you haven't received a reply or request for your manuscript.
If the author representative who rejects your book says your book is not right for "us" or "our literary agency," however, you should not query the next book agent at the literary agency.