This question runs in a pre-configured Salesforce environment - no personal connection required.
Given a list of Opportunity records and a cutoff date, update all open opportunities (where IsClosed is false) whose CloseDate is before the cutoff date by setting their StageName to Closed Lost. Return the count of updated records. Use bulk-safe DML - do not perform DML inside a loop.
Examples:
Input: opps = [list of opportunities], cutoffDate = 2026-01-01
Output: 5
Explanation: 5 open opportunities have a CloseDate before 2026-01-01
Input: opps = [], cutoffDate = Date.today()
Output: 0
Explanation: Empty list returns 0
Input: opps = [closed opportunity], cutoffDate = 2030-12-31
Output: 0
Explanation: Already closed opportunities are not updated
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • This challenge runs without connecting your own org
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay September 2026 (Sep 1–15)Sponsored by FLXBL
Contest runs September 1 - 15. Complete challenges to climb the leaderboard!
1st & 2nd: Salesforce certification exam voucher — see all prizes
Only the 15 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.