That question is not easily answered, because it depends entirely on what you are writing. Some projects require months of research, others only need that special "Ah!" moment when a story somehow inserts itself in the mind of the unsuspecting writer.
Now that I've claimed the question can't be answered, I am going to answer it in a most unsatisfactory manner: Like childbirth, writing a book takes as long as it takes. If you are on a manic roll, it can take a couple of months. (One of my novels took only a few weeks to write. At 90,000 words, it was an exhilarating and exhausting experience.) If you are grappling with the text, writing your book can take decades. (It has taken me twenty years, so far, to finish another one of my novels. It is only 55,000 words, so I have no idea why this book is proving so stubborn.)
If you are stuck on a project, putting it down for a while can be enormously helpful. You may find that your unconscious continues to work on it, even when you are not writing. Working on other projects is also quite helpful. I usually write two books at once. That way, when I hit a snag with one, I can simply switch off to the other.
Writing in another genre is extremely liberating. If you are a novelist, write nonfiction. If you write long form, write a short story. Write a screenplay if you have never written one. By stretching yourself in different directions, whatever roadblock preventing you from finishing your book will be removed.
The important thing is to keep writing. Write anything. It is not important what you write, it is only important that you write.
Here are some famous books whose writers either took their time, or dashed them off in a rush. As you can see, how long it took to write these books has little to do with their quality.
At one end of the spectrum, John Boyne said that he wrote the entire first draft of The Boy in the Striped Pajamas in two and a half days, barely sleeping until he finished it. At 44,800 words, that amounts to 747 words an hour. It's quite possible to dash off 700 words for a few hours - that is how many of us write our short stories - but sustaining that kind of output for days is hard to imagine.
Other books on the short end of the scale include: The Strange Case of Dr. Jekyll and Mr. Hyde (6 days), A Clockwork Orange (3 weeks), A Study in Scarlet (3 weeks), A Christmas Carol (6 weeks), and As I lay Dying (6 weeks).
At the far end of the spectrum is J. R. R. Tolkien, who took 16 years to complete the Lord of the Rings. At 455,000 words, that amounts to 28,000 words a year, roughly the length of a novella.
Les Miserables took Victor Hugo 12 years to write, Catcher in the Rye and Gone with the Wind each took ten years, and Harry Potter and the Philosopher's Stone took five.
Realistically, your book should fall somewhere between Boyne's and Tolkien's.