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
khushi Yadavkhushi Yadav 

To fetch out the Month in text data type from the DOB & show the month name in a different field.

Rounak SharmaRounak Sharma

hello Khusi,

Can you please elaborate your requirement a little more.

thanks

khushi Yadavkhushi Yadav
I created two custom fields one is DOB and other is month and i want to fetch the month  from the DOB field  in text format
 
Rounak SharmaRounak Sharma
you can fetch the string from the field and from split string method in salesforce and index of method you can take out the month from it
later on you can assign that string to the other field.
Rounak SharmaRounak Sharma

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm

you can refer this link for the string part.

Please mark it as the best answer if it helped you.

khushi Yadavkhushi Yadav
It Simply done by formula function but the problem is that i dont know what to write exact because month is visible but in number format and i want in text format
Rounak SharmaRounak Sharma
you can use this TEXT(MONTH(Date__c))+"/" +TEXT(DAY(Date__c))+"/" +TEXT(YEAR(Date__c)) formuale which will change the format to text
Ajay K DubediAjay K Dubedi
Hi 
khushi Yadav ,
 
List<Account> accList = [SELECT id,name,DOB__c,monthValueField FROM Account WHERE Id = '0010o00002X1BQC'];
String month = String.valueOf(accList[0].DOB__c.month());
String monthValue = '';
if(month.equals('1')){
    monthValue = 'January';
}else if(month.equals('2')){
    monthValue = 'Feburary';
}else if(month.equals('3')){
    monthValue = 'March';
}else if(month.equals('4')){
    monthValue = 'April';
}else if(month.equals('5')){
    monthValue = 'May';
}else if(month.equals('6')){
    monthValue = 'June';
}else if(month.equals('7')){
    monthValue = 'July';
}else if(month.equals('8')){
    monthValue = 'August';
}else if(month.equals('9')){
    monthValue = 'September';
}else if(month.equals('10')){
    monthValue = 'October';
}else if(month.equals('11')){
    monthValue = 'November';
}else if(month.equals('12')){
    monthValue = 'December';
}
accList[0].monthValueField = monthValue;
update accList;

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com