This is a difficult question to answer. My experiences are:
My first novel (Prophecy of the Kings) took many years to write and re-edit on many occasions. My more recent novel (Drachar's Demons) only took me about 5-6 months to write and then about the same to have it edited. So what's the main difference between the two timescales?
My first book was a learning experience and my English developed over writing the trilogy, I also didn't have a particular drive to deliver and so I could take my time. A lot of time was spent on the plot, which I hadn't formulated before hand and which developed as I wrote. There were long periods where writer's block was a real problem with my heroes trapped in a seemingly impossible situations. It took months to think through a way forward and often inspiration struck at unlikely times. I have a separate blog on writing a plot.
Drachar's Demons was different as it was a prequel. I had the plot pretty much mapped out, having written the trilogy. However, what the tale lacked was the detail and the characterisation.
So, how long might it take you to write a book? The key is having the plot already developed and not being tripped up along the way. I think I can manage about 4-5 pages per day. That's nearly a chapter. Assuming 30 chapters then I could write a book in a month, assuming no sticking points. Would the book be good? Very unlikely? At this rate of writing there's likely to be plot holes and inconsistencies in the tale, like having 5 donkeys on moment and 6 the next. It takes time to resolve these issues and often chapters need a rewrite. The editing process can be slow. If you have a full edit, the editor will help to find inconsistencies and may suggest re-ordering chapters. That's a lot of work. This process can add several months.
A copy edit is quicker as they are looking at spelling and grammar mainly and so edits can be turned around reasonably quickly.
Self publishing requires cover designs and layout of the typeface. Again, this is a lengthy process, Learning to use the self-publishing tools is an experience and can introduce significant delays. I had a particular problem with one package on Smashwords and it was getting books published to itunes. The difficulty was indexing the chapters and that was a nightmare. The slightest mistake meant the publication was rejected.
So the answer to the question, how long does it take to write a book is about one month, assuming the plot is already pretty much developed and you can face writing 5 pages per day. However, getting it to print would take about a year. Some established authors may be a lot faster as they will have an editor and book publisher on hand to help. The self publishing route adds considerable time.
Any authors with a different experience, drop me a line and let me know.
My 400 page doctoral dissertation took about a year to write. My first novel took only three months (typing one finger at a time), but it was only 65 pages and covered 6000 years. My autobiography took 22 years, largely because I wrote it occasionally while off work, stopped a few times, and my life, of course, got longer and required more writing.
While I have many past publications: research articles, poems newsletters, and a monograph published in the traditional way, I started self-publishing when I wrote an edited newsletters many years ago. Through that process I learned formatting and how to incorporate images and diagrams as well as reproduce and distribute what was published. These things came almost naturally just by copying what I observed in magazines, newspapers and books. Amsterdam there
There are many ways to self publish. Most are there for your money and not for your benefit. Like David suggests, self editing is the first requirement, and if you're not good at it, be sure you have someone edit your work that is. Paying a lot for editing may not help at all. I find graphics quite easy and have designed my own covers taking very little time at all. In a couple of cases, I sent out multiple ideas to friends and asked them for their opinion on which cover they liked the best.
Unfortunately, the simple to use software, MacDraw Pro and an earlier, easy to use, Photoshop 2.5 that I used to do my first covers is obsolete and the replacement software I have found is much harder to use and in some cases, doesn't work for me. So, I have relied on a professional cover designer for two of my covers. I find cover designers unwilling to come up with optional covers but want the author to settle on a single design with minimal adjustments.
I also use my POD publisher to do all the formatting for iTunes, Kindle, and Nook. If I publish on my website, I do it myself with simple HTML tags. I can still send out signed (I simply scanned
my signature in blue) copies of my books in eformat in Microsoft Word. If you want to be more secure you can convert your Word document into PDF with a converter like OmniPage. In this day and age, it's not about books on shelves anymore. It's about readership. The more an author can get his or her work read, the more success he or she will have. One caveat. People only want to read your work if it is good (and well edited to meet standard English practices). Encouragement by family and friends is not a good source of gauging your writing ability.
Ron