You need to sign in to do that
Don't have an account?
Display Day
Hello. Sorry if this seems like a stupid question but it's been driving me crazy. I've tried different formulas and nothing seems to work.
I have a report that shows created cases and its set in the Matrix format. I have the opened date on the left. When I choose a grouping type and choose day I get the date and not the day of the week. I also try to group by "Calendar Day in Month" but still can't get the graph to report the actually day of the month.
Any help would be greatly appreciated. Thank you.
Also, i get the following when trying to use the date formula.
Hi I can give you this java script method that returns the day
In this leap year calculation is not right
Update this to calculate it rightly as 1900 will be a leap year by this but it is not.
Any year which has last 2 digits 00 like 1600,1800, 1900, 2000, are divided by 400 not by 4, update this logic and you will get the Day
if(year%4 == 0)
Use this one your formula field which should have return type 'Text'
IF(MOD(DateFieldAPIName__c - DATE(0001,1,1) , 7) == 0 , 'Saturday' , IF(MOD(DateFieldAPIName__c- DATE(0001,1,1) , 7) == 1 , 'Sunday' ,
IF(MOD(DateFieldAPIName__c- DATE(0001,1,1) , 7) == 2 , 'Monday' ,
IF(MOD(DateFieldAPIName__c- DATE(0001,1,1) , 7) == 3 , 'Tuesday' ,
IF(MOD(DateFieldAPIName__c- DATE(0001,1,1) , 7) == 4 , 'Wednesday' ,
IF(MOD(DateFieldAPIName__c- DATE(0001,1,1) , 7) == 5 , 'Thursday' ,
IF(MOD(DateFieldAPIName__c- DATE(0001,1,1) , 7) == 6 , 'Friday' , 'No Day'))))))
)
You can also Use Case instead of IF in formula like this :
CASE(MOD(DateFieldAPIName__c - DATE(0001,1,1) , 7) , 0 , 'Saturday' , 1 , 'Sunday' , 2 , 'Monday' , 3 , 'Tuesday' , 4 , 'Wednesday' , 5 , 'Thursday' , 6 , ' Friday' , 'No Day Found')
To see more on this how to calculate day in Apex Class see :
http://forceschool.blogspot.com/2011/06/calculate-day-of-date-in-apex.html
A bit more optimized formula :)
https://sfdcadda.blogspot.in/2017/05/insert-day-name-by-providing-date-using.html
Blog