function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Niranjan Reddy @ 22Niranjan Reddy @ 22 

Hi can anyone help me out how to extract string of the day from given date i am getting date in mm/dd/yyyy format from this i want to get day in the string format like Sunday,Monday and soo on in apex class

Khan AnasKhan Anas (Salesforce Developers) 
Hi Niranjan,

Greetings to you!

You can use DateTime.format() function: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_datetime.htm#apex_methods_system_datetime
DateTime myDateTime = (DateTime) System.today();
String dayOfWeek = myDateTime.format('EEEE');

Please refer to the below links which might help you further with the above requirement.

https://salesforce.stackexchange.com/questions/1192/how-can-i-tell-the-day-of-the-week-of-a-date

http://forceschool.blogspot.com/2011/06/calculate-day-of-date-in-apex.html

https://salesforce.stackexchange.com/questions/99098/date-formateeee-doesnt-give-day-of-week

I hope it helps you.

Kindly 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. It will help to keep this community clean.

Thanks and Regards,
Khan Anas