Theforaginggene is a key genetic factor that modulates social behavior in insects, primarily by governing the trade-off between individual foraging and group-related activities. It has been associated with various behaviors associated with food search and resource exploitation, thereby playing a crucial role in determining the efficiency of foraging and the overall success of the collective. In this study, we investigate the critical role of theforaginggene in mediating complex interval timing behaviors, particularly mating duration, in the fruit flyDrosophila melanogaster. By examining two distinct variant phenotypes, rover and sitter, we observe specific deficiencies in longer (LMD) and shorter mating duration (SMD) behaviors, respectively, suggesting the gene’s crucial influence on these interval timing mechanisms. Utilizing single-cell RNA sequencing and knockdown experiments, we identify the gene’s significant expression in key neurons involved in learning and memory. However, its impact on mating duration is not observed in these brain regions. Instead, our data reveal the gene’s crucial role in specific neurons expressing Pdfr, a critical regulator of circadian rhythms. Furthermore, the study uncovers sexually dimorphic expression patterns in the brain and highlights the necessity of the gene’s dosage in specific cell populations within the ellipsoid body for normal mating duration. These findings underscore theforaginggene’s pivotal role in mediating complex interval timing behaviors inDrosophila, providing valuable insights into the intricate interplay between genetics, environment, and behavior. This research contributes to a deeper understanding of the genetic and neural mechanisms underlying complex interval timing behaviors, with broader implications for unraveling the function offoraginggene.