You need to sign in to do that
Don't have an account?
Kiran kumar 193
Return date by substracting 2 days from Priority date and Need to exclude weekends
Hi,
My requirement is is Return date by substracting 2 days from the Priority date and Need to exclude weekends.
If Priority date is
MONDAY (ex: 4/26/2021)- Return last THRUSDAY Date(4/22/2021)
TUESDAY(ex: 4/27/2021)- Return last FRIDAY Date(4/23/2021)
WEDNESDAY(ex: 4/28/2021)- Return MONDAY Date(4/26/2021)
THRUSDAY(ex: 4/29/2021)- Return TUESDAY Date(4/27/2021)
FRIDAY(ex: 4/30/2021)- Return WEDNESDAY Date(4/28/2021)
Below logic is working fine for wednesday,thrusday,friday dates but for monday,tuesday it was returning weekend dates. Appriciate help
CASE(
MOD( DATEVALUE(Priority_Date__c)- DATE(1900, 1, 2), 2),
0, Priority_Date__c-4,
1, Priority_Date__c-2,
2, Priority_Date__c-2,
3, Priority_Date__c+1,
4, Priority_Date__c+1,
5,Priority_Date__c+3,
6,Priority_Date__c+2,
Priority_Date__c)
My requirement is is Return date by substracting 2 days from the Priority date and Need to exclude weekends.
If Priority date is
MONDAY (ex: 4/26/2021)- Return last THRUSDAY Date(4/22/2021)
TUESDAY(ex: 4/27/2021)- Return last FRIDAY Date(4/23/2021)
WEDNESDAY(ex: 4/28/2021)- Return MONDAY Date(4/26/2021)
THRUSDAY(ex: 4/29/2021)- Return TUESDAY Date(4/27/2021)
FRIDAY(ex: 4/30/2021)- Return WEDNESDAY Date(4/28/2021)
Below logic is working fine for wednesday,thrusday,friday dates but for monday,tuesday it was returning weekend dates. Appriciate help
CASE(
MOD( DATEVALUE(Priority_Date__c)- DATE(1900, 1, 2), 2),
0, Priority_Date__c-4,
1, Priority_Date__c-2,
2, Priority_Date__c-2,
3, Priority_Date__c+1,
4, Priority_Date__c+1,
5,Priority_Date__c+3,
6,Priority_Date__c+2,
Priority_Date__c)
>> https://salesforcemann.wordpress.com/2016/12/04/the-ultimate-salesforce-formula-to-add-business-days-to-a-date/
In the above link, there is an explanation of how to add business days I think you can use the same and alter it to subtract that will fit your use case.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Thanks