You need to sign in to do that
Don't have an account?
Salesforce@322
Fetching the previous week data of the object
Hi Salesforce Friends,
How to fetch the latest previous week data in salesforce?
My requirement is : Need to fetch records from a custom object which has been created past week.
If there is no record for past week, need to fetch the latest previous week.
If there is no record for that week also need to fetch the previous week of that week ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,etc
Kindly help me on how to fetch the latest previous week data.
Thanks ,,,,,,,,,,,,,
How to fetch the latest previous week data in salesforce?
My requirement is : Need to fetch records from a custom object which has been created past week.
If there is no record for past week, need to fetch the latest previous week.
If there is no record for that week also need to fetch the previous week of that week ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,etc
Kindly help me on how to fetch the latest previous week data.
Thanks ,,,,,,,,,,,,,
You can use where clause in soql where. By below code you can get the record which are created last 7 days Previous to previous to week record can get by below get.
Hope this code help you use this code according to your need in IF condations,
Please mark it as solution if helps you. Enjoying APEX
You can use Date functions like LAST_WEEK, LAST_MONTH, THIS_WEEK etc, but your requirement is to get data for latest previous week right? so you have to first identify which previous week has data and based on that you can query. This would require 2 queries altogether,
One to get the latest previous week,
Hope this helps
This is quick. See below example:
Also refer: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm
Hope this helps.