A closed formula for the Hodrick & Prescott, HP, filter subject to linear restrictions is derived. This filter is also known as the HP filter with priors. When the formula is applied to the ordinary HP filter linear restrictions apply only within the sample. However, when this formula is applied to the extended HP filter and extensions that correct for GDP revisions and delays, linear restrictions apply out of sample also.