Activity Forums Salesforce® Discussions In Salesforce, how can I tell the day of the week on a date?

  • Surbhi

    Member
    September 7, 2016 at 6:18 am

    Hi Mohit,

    You can try the below code:

    Datetime dt = DateTime.newInstance(Date.today(), Time.newInstance(0, 0, 0, 0));
    String dayOfWeek=dt.format('EEEE');
    System.debug('Day : ' + dayOfWeek);

    Thanks

  • Tanu

    Member
    September 7, 2016 at 6:29 am

    Hello Mohit,

    Date daytofind = Date.newInstance(Year, Month, Day);

    Try this example,

    Date daytofind = Date.newInstance(2016, 9, 6);
    DateTime myDateTime = (DateTime) daytofind;
    String dayOfWeek = myDateTime.format('E');

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos