This question runs in a pre-configured Salesforce environment - no personal connection required.
Query and return all Account records that were created in the current calendar year. Use the CreatedDate field with date literals or date functions. Return the accounts sorted by CreatedDate in descending order (newest first).
The method should handle cases where no accounts were created in the current year by returning an empty list.
Examples:
Input: (no parameters)
Output: List of Account records created in the current year
Explanation: If today is 2025-01-13, return all accounts with CreatedDate in 2025, sorted by CreatedDate DESC
Input: (no parameters)
Output: Empty list
Explanation: If no accounts were created in the current year, return an empty list
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
Note
You can test your code by connecting to Salesforce, but to save your progress and earn points, you'll need to create an account. Your solutions and achievements will be tracked automatically once you're logged in.