Activity Forums Salesforce® Discussions How can we calculate number of days excluding weekend values in salesforce?

  • Ajit

    October 14, 2016 at 3:47 pm

    Hi Pranav,

    Try this code :

    Integer numberDays = Date.daysInMonth(2016, 2);
    integer counter=0;
    for(integer i=0; i<numberDays; i++){
    Date dt = date.newInstance(2016, 1, 1+i);
    String dayOfMonth=dt.format('EEEE');

    if(dayOfMonth != 'Saturday' && dayOfMonth != 'Sunday'){


Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos