If your trying to know the starting date of the week for the given date in salesforce please use the below 2 formats.
Using the Formula Fields:
The return type of the formula is date.
(Yourdatefield__c- MOD(Yourdatefield__c- DATE(1900, 1, 7), 7))
Using the Apex:
In case of apex we can use the salesforce in built date function called toStartofWeek() which returns the start date of week basis on the user locale.
- Sunday will be treated as US locale
- Monday in case of European locale
Date startWeek = Yourdatefield__c.toStartofWeek();
In my case given date is 20th Friday and start of the week will returns as 15th on Sunday
Please comment or write us if you have any queries/requirements.
Please like,follow,bookmark,subscribe this site to receive daily updates.
Please like,follow,bookmark,subscribe this site to receive daily updates.
No comments:
Post a Comment