Given two date ranges defined by their start and end dates (inclusive), determine whether the ranges overlap. Two ranges overlap if there is at least one date that falls within both ranges. Ranges that share only an endpoint (e.g., one ends on the same day the other begins) are considered overlapping. Return false if any of the four date parameters is null.

Examples:

Input: start1 = 2026-01-01, end1 = 2026-01-15, start2 = 2026-01-10, end2 = 2026-01-25 Output: true Explanation: The ranges share the dates January 10 through January 15 Input: start1 = 2026-01-01, end1 = 2026-01-10, start2 = 2026-02-01, end2 = 2026-02-10 Output: false Explanation: The ranges do not share any dates Input: start1 = 2026-01-01, end1 = 2026-01-15, start2 = 2026-01-15, end2 = 2026-01-30 Output: true Explanation: The ranges share the single endpoint January 15 Input: start1 = null, end1 = 2026-01-15, start2 = 2026-01-10, end2 = 2026-01-25 Output: false Explanation: Null date parameter returns false
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • Connect your Salesforce org to test
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay October 2026 (Oct 16–31)Sponsored by FLXBL

Contest runs October 16 - 31. Complete challenges to climb the leaderboard!

Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes

Only the 16 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In