Given a year and month (as integers), calculate the total number of workdays (Monday through Friday) in that month. Do not account for holidays - just count weekdays.

Return the count as an Integer. Return null for null inputs. Return 0 for invalid months (less than 1 or greater than 12).

Examples:

Input: year = 2026, month = 2
Output: 20
Explanation: February 2026 has 20 weekdays (Monday-Friday)

Input: year = 2024, month = 2
Output: 21
Explanation: February 2024 is a leap year with 29 days and 21 weekdays

Input: year = 2026, month = 1
Output: 22
Explanation: January 2026 has 22 weekdays

Input: year = 2026, month = 13
Output: 0
Explanation: Month 13 is invalid, return 0

Input: year = null, month = 2
Output: null
Explanation: Null input returns null

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 account

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 Feb 2026

Contest runs February 1 - 28. Complete challenges to climb the leaderboard!

Points are calculated for challenges completed during the contest period.