Studying the effect of duration of treatment on prognostic outcomes using real-world data is challenging because only people who survive for a long time can receive a treatment for a long time. Specifying a target trial helps overcome such challenge. We aimed to estimate the effect of different durations of treatment with antihypertensive drugs with anticholinergic properties (AC AHT) on the risk of vascular dementia and Alzheimer’s disease by emulating a target trial using the UK CPRD GOLD database (2001-2017). Comparing treatment for 3-6 years versus ≤3 years yielded null results for both types of dementia. Comparing a longer duration of treatment, >6 years versus ≤3 years, yielded a 10-year risk ratio of 0.69 (95% CI, 0.54-0.90) for vascular dementia and 0.91 (95% CI, 0.77-1.10) for Alzheimer’s disease. For illustration, we performed an analysis that failed to emulate a target trial by assigning exposure categories using postbaseline information, obtaining implausible beneficial estimates. Our findings indicate a modest benefit of longer duration of treatment with AC AHT on vascular dementia and highlight the value of the target trial emulation to avoid selection bias in the evaluation of the effect of different durations of treatment.