Sometimes the Salesforce requirements are so over-hyped that we do not realize their solution would be so easy. I got a similar requirement in Salesforce where a date field on the case object need to be converted to Days of week for SalesforceCommunication email templates. The formula is really simple to achieve this requirement.
Formula for converting a Date into Days of Week:
CASE( MOD( Date__c - DATE(1900, 1, 7), 7), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3,
"Wednesday", 4, "Thursday", 5, "Friday", 6, "Saturday","Error")
Explanation: This formula is an example of CASE() function in Salesforce. The crux of the formula is that 1/7/1900 is subtracted from the desired date and the result is divided by 7 to get an index of Day of week.
- Create a Text Formula field on Case object and use the below formula to achieve the goal.
Formula for converting a Date into Days of Week:
CASE( MOD( Date__c - DATE(1900, 1, 7), 7), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3,
"Wednesday", 4, "Thursday", 5, "Friday", 6, "Saturday","Error")
Explanation: This formula is an example of CASE() function in Salesforce. The crux of the formula is that 1/7/1900 is subtracted from the desired date and the result is divided by 7 to get an index of Day of week.
No comments:
Post a Comment