You need to sign in to do that
Don't have an account?
Michael Kolodner 13
SOQL query for "two fiscal years ago"?
I need to write a soql query for DLRS that will return records with a date in the year prior to "last fiscal year." Is there soql syntax that will return "2 fiscal years ago"?
My current query is
Select ID from School_Report_Card__c WHERE School_Year_of_This_Report_Card__c = Last_Fiscal_year
But I need the year before that. Is this possible?
My current query is
Select ID from School_Report_Card__c WHERE School_Year_of_This_Report_Card__c = Last_Fiscal_year
But I need the year before that. Is this possible?
Check documenations Date Formats and Date Literals (https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm) for details.
All Answers
Check documenations Date Formats and Date Literals (https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm) for details.
No, the last fiscal year literal works from the starting and ending of given year number. For example -
If your company fiscal years are defined from Jan 1 to Dec 31 then
LAST_N_FISCAL_YEAR:1 will return all records for current year 2019 [from Jan 1, 2019 to Dec 31 2019]
LAST_N_FISCAL_YEAR:2 will return all records for current year 2019 [from Jan 1, 2018 to Dec 31 2018]
Above soql should return all Report Card records where report card is 2018 FY. Try running this query and see if you get the right results.
Let me know if this helps.
Here's a report showing them by year:
Here's the query result:
Can you check Fiscal year settings in your org? Here is the description from SF documentation-
LAST_N_FISCAL_YEARS:n
Starts 00:00:00 on the first day of the last fiscal year and continues through the end of the last day of the previous nth fiscal year. The fiscal year is defined on the Fiscal Year page in Setup.