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
bgm1234bgm1234 

get the day of month using apex class

hi

 

 

from a list iam getting a date  how to find day of week for particular date using apex class

Best Answer chosen by Admin (Salesforce Developers) 
gbu.varungbu.varun

If you want to find day as Sunday, Monday, etc. You can achieve it as:

 

Datetime dt = DateTime.newInstance(Date.today(), Time.newInstance(0, 0, 0, 0));

dayOfWeek = dt.format('EEEE');

System.debug(dayOfWeek);

All Answers

Vinita_SFDCVinita_SFDC

Hi,

 

There is no built in fuctionality but you can implement this. Please refer following link for logic and code :

 

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

gbu.varungbu.varun

Hi If you are getting date than you can find day in such a way:

 

Date d =date.today();

String day = String.valueOf(d.day());

 

thanks,

 

gbu.varungbu.varun

If you want to find day as Sunday, Monday, etc. You can achieve it as:

 

Datetime dt = DateTime.newInstance(Date.today(), Time.newInstance(0, 0, 0, 0));

dayOfWeek = dt.format('EEEE');

System.debug(dayOfWeek);

This was selected as the best answer