In general, the numbers you want to remember are 8, 18, 48, 72.
Under 8 months is perceived to be terrible, unless you can point to an objective reason (such as a large corporate action). It suggests that you didn't pass your 6-month review or the first performance cycle. You may want to omit the job and move any accomplishments to your freelance section, or include the job but say it was a project-specific contract role, and that you were offered more projects but declined. Yes I'm advocating that you omit something on your resume. Some things are so bad that you should drop them, and jobs under 8 months almost always qualify.* As long as you don't make accomplishments up, it's not the deceptive and unethical type of lie. You're not trying to mislead anyone about yourself; you're cleaning your past to avoid wasting the interviewer's time on irrelevant issues about things that've happened to you.
*One exception is if you're affected by a news-making layoff in the first year, or ever. An unannounced small layoff (under 5% of your division) will be assumed to be performance-related and you should hide it, but when you're affected by a known layoff (such as a plant closing) that everyone knows about, there's no shame in it. With, say, a 7-month job that ended due to a large-scale, non-performance layoff you are better off to list it than hide it.
18 months is the socially accepted minimum. It suggests that you survived at least one review cycle-- reviews are presumed to be annual, and people aren't reviewed until 6 months old; that's where the 18-month derivation comes from-- and had to achieve something to be retained for that long. You can go down to 9 if you have a really good explanation, like a corporate action (merger, upper management change) that affected the nature of your work, or a family-related reason. If you come in under 18 months for some reason, it helps if you can establish that you did pass at least one performance review. (A bonus, or a round of layoffs that you survived, would suffice.) Even then, you can't have too many of those, however. If you had one job where you were (possibly unintentionally) bait-and-switched and left at 8 months, that's understandable. If you have five, it looks like the problem is you. Similarly, if you leave every time the nature of the work changes, HR cynics will be skeptical. (I see that as an admirable selectiveness in the work one does, but I don't make the rules.) If your story is that you keep getting bait-and-switched (because it is, well, common) the HR cynics will think that you go into jobs with unreasonable expectations.
Unless the job is terrible, you should try to make it span, at the minimum, 15 months spanning three calendar years (e.g. Oct. '14 to Jan. '16) or 18 months spanning two. I don't like these rules, and a lot of companies abuse people during the 6-17 month spell (before the 6-month mark, the job can just be taken off the resume) because they are captive, but that's how it is.
All else being equal, 2 years is better than 18 months, and 3 years is better than 2, and 4 is better than 3. The advantage gained each month isn't enough to merit passing up obviously superior opportunities, but it does mean that you're best off to avoid movements that don't have an obvious benefit.
Four years (48 months) will get you "full credit" for working there, unless something makes it clear that you were an underperformer or stagnating. If you had increasing scope of accomplishment and preferably at least one title change, you're fine. If you haven't been promoted and your projects aren't getting better, you're still OK at this point but you have two years in which make your next move.
Six years (72 months) is the point at which it starts to hurt you if you're not getting promoted or better projects. Four years with a on-boarding year and then a flat trend or lateral moves for three is fine. Four years means you did your job, gave the company a thorough chance, didn't piss too many people off, and moved on. After 6 years without an obvious record of promotions, it suggests that a person is unambitious and, while not so terrible as to be unable to keep a job, thoroughly mediocre. If you keep getting promoted, however, there's no upper limit on how long you can stay at a job.