# Prevent Opportunity Close Date from Moving Backward

**Type:** Apex trigger · **Difficulty:** Medium · **Object:** Opportunity · **Topics:** Opportunity, Trigger.oldMap, Before Update

Practice this problem interactively (write and run your Apex trigger against realistic data): https://www.forcechallenges.com/problems/prevent-opportunity-close-date-moving-backward

## Problem

When an Opportunity is updated, do not allow its Close Date to be changed to an earlier date than it had before. Keeping the same date or moving it later is allowed.

## Constraints

Write bulk-safe trigger logic. Do not run SOQL or DML inside a loop.

---
Source: ForceChallenges · last updated 2026-10-13
