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 October 2026 (Oct 4–15)Sponsored by FLXBL
Contest runs October 4 - 15. 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 12 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.