Cancer is more frequent among diabetes patients, but it is unknown how this excess varies with duration of diabetes and insulin use. The aim of this study was to analyse disease data to examine this issue further. We linked the Danish National Diabetes Register and Cancer Registry and performed a cohort analysis of the entire Danish population by diabetes status, duration of diabetes and insulin use, comparing cancer incidence rates in diabetic patients with the non-diabetic population for the 15 year period 1995-2009, using Poisson regression with natural splines to describe the variation by duration. We found 20,032 cancer cases among patients not using insulin and 2,794 cancer cases among diabetic patients using insulin. The cancer incidence rate ratio among non-insulin users relative to the non-diabetic population decreased from over 2 at diagnosis to 1.15 after 2 years of diabetes duration. The cancer incidence rate ratio was higher among patients using insulin, decreasing from 5 at the start of insulin treatment to about 1.3 [corrected] after 5 years of insulin use. Among non-insulin users, cancers of the stomach, colorectum, liver, pancreas, lung, corpus uteri, kidney and brain, and lymphomas were elevated. Among insulin users the rate ratio of prostate cancer was decreasing by duration whereas we found higher risk of cancer of the stomach, lung, liver, pancreas and kidney. Breast cancer incidence rates were not affected by either diabetes or insulin use. The observed duration effects suggest that both increased surveillance for cancer in the first years after diagnosis of diabetes, and reverse causation, where undiagnosed cancers increase the likelihood of diabetes diagnosis, play a role. For longer durations, a combination of common causes for diabetes and cancer, as well as the effects of diabetes and insulin exposure per se, may play a role in the association between diabetes and some cancers.