Given a date, return the fiscal quarter number (1-4) based on calendar quarters. Q1 is January-March, Q2 is April-June, Q3 is July-September, Q4 is October-December. Return null if the input date is null.
Examples:
Input: inputDate = Date.newInstance(2025, 2, 15)
Output: 1
Explanation: February is in Q1 (January-March)
Input: inputDate = Date.newInstance(2025, 7, 1)
Output: 3
Explanation: July is in Q3 (July-September)
Input: inputDate = Date.newInstance(2025, 12, 31)
Output: 4
Explanation: December is in Q4 (October-December)
Input: inputDate = null
Output: null
Explanation: Null input returns null
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 July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.