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!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow 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 Mar/April 2026
Contest runs March 3 - April 30. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.