Skip to main content
I'm working on a trigger where i need to convert month name to integer value and i dont want to hard code like 'jan' = 1. Plz suggest.
6 件の回答
  1. 2016年2月26日 7:07
    DateTime d = datetime.now();

    Integer count = 1;

    Integer dtMonth = 0;

    while (count < 13) {

         String monthName = d.format('MMMMM');

         monthName = monthName.substring(0,3);

          If(monthName == 'Compare your picklist value'){

                dtMonth = d.month();

                System.debug(dtMonth);

                break;    

         }

         else{

             d = d.addMonths(1);

             count++;

         }

    }       
0/9000