In this study, changes in gene effects for milk production traits were analysed over time. Such changes can be expected by investigating daily milk production yields, which increase during the early phase of lactation and then decrease. Moreover, additive polygenic effects on milk production traits estimated in other studies differed throughout the 305 days of lactation, clearly indicating changes in the genetic determination of milk production throughout this period. Our study focused on particular candidate genes known to affect milk production traits and on the estimation of potential changes in the magnitude of their effects over time. With two independent data sets from Holstein-Friesian and Jersey breeds, we show that the effects of the DGAT1:p.Lys232Ala polymorphism on fat and protein content in milk change during lactation. The other candidate genes considered in this study (leptin receptor, leptin and butyrophilin, subfamily 1, member A1) exhibited effects that vary across time, but these could be observed in only one of the breeds. Longitudinal modelling of SNP effects enables more precise description of the genetic background underlying the variation of complex traits. A gene that changes the magnitude or even the sign of its effect cannot be detected by a time-averaged model. This was particularly evident when analysing the effect of butyrophilin, missed by many previous studies, which considered butyrophilin's effect as constant over time.