The idea that it takes 21 days to change a habit is based on a work in 1960 by a cosmetic surgeon named Maltz who surmised that it took at LEAST 21 days for an amputee to adjust to losing their limb. This knowledge was then extrapolated over the decades to mean that any habit could be changed after 21 days.
In 2009, study results published by Phillippa Lally in European Journal
of Social Psychology found that rather than taking 21 days, study
participants took anywhere from 18 to 254 days to form a new habit with
an average of 66 days. The new 66-day rule has become a popular
counterclaim to the original 21-day rule, but even this study was
limited to a sample size of less than 100 volunteer participants.
http://vancouver.24hrs.ca/2014/02/23/21-day-habit-formation-theory-is-myth-2