Hello friends, In this post you will see a code example that shows you, how you can get the name of day from date using apex code.

Get day name from date in apex

In apex, we can get day name in two different formats. Each posted with example in this section.

1) Short Day Name : Use following code snippet to get short day name. 

 Datetime targetDate = System.today();
String dayOfWeek = targetDate.format('E');
System.debug('DayName-> '+dayOfWeek);

Output:


 2) Full Day Name : Use following code snippet to get full day name.

 Datetime targetDate = System.today();
String dayOfWeek = targetDate.format('EEEE');
System.debug('DayName-> '+dayOfWeek);

Output:

Hope you like this post, for any feedback or suggestions please feel free to comment. I would appreciate your feedback and suggestions.
Thank you.