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
VSK98VSK98 

I have one text field , but i want only month like as jan,Feb,mar etc............

Hi All,

I have been facing the issue while writing the formula field taken the return type is text

here is the formula
CASE(MONTH(example__c) ,
1, "January", 
2, "February", 
3, "March", 
4, "April", 
5, "May", 
6, "June", 
7, "July", 
8, "August", 
9, "September", 
10, "October", 
11, "November", 
12, "December", 
"None" 
)

The data should be like dis 3/30/2016 in example__c, Getting error as Syntax error

Adv Thnx
Siv
Best Answer chosen by VSK98
DebasisDebasis
Hi 

if your field is a text field and then you can use below formula for month. here you can replace your field inplace of SicDesc. this formula can handel both 03/23/2016 and 3/23/2016 also. 
if( BEGINS(SicDesc, '0'), 
CASE( left(SicDesc,Find("/",SicDesc)-1), 
'01', "January", 
'02', "February", 
'03', "March", 
'04', "April", 
'05', "May", 
'06', "June", 
'07', "July", 
'08', "August", 
'09', "September", 
'10', "October", 
'11', "November", 
'12', "December", 
"None" 
), 
CASE( left(SicDesc,Find("/",SicDesc)-1), 
'1', "January", 
'2', "February", 
'3', "March", 
'4', "April", 
'5', "May", 
'6', "June", 
'7', "July", 
'8', "August", 
'9', "September", 
'10', "October", 
'11', "November", 
'12', "December", 
"None" 
))
User-added image


please do let mek now if it helps you.
Thanks,
Debasis
 

All Answers

Tavva Sai KrishnaTavva Sai Krishna
Hi Vsk,

You have to convert the text field to date field then only the month() formula will work syntatically. try the below updated code
 
CASE(MONTH( DATEVALUE( SLASerialNumber__c)  ),
1, "January",
2, "February",
3, "March",
4, "April",
5, "May",
6, "June",
7, "July",
8, "August",
9, "September",
10, "October",
11, "November",
12, "December",
"None"
)

Let me know if you have any issues.

Regards,
Sai Krishna Tavva.
VSK98VSK98
Thx for ur Replied,i can't convert text to date datatype , bcz this field used in more apex classes.................i need Above output with text data type only
DebasisDebasis
Hi VSK98,

is example__c is a date type field?
To take the month part from a date fiedl you can use below code
 
CASE(MONTH(example__c) ,
1, "January", 
2, "February", 
3, "March", 
4, "April", 
5, "May", 
6, "June", 
7, "July", 
8, "August", 
9, "September", 
10, "October", 
11, "November", 
12, "December", 
"None" 
)
as example__c is a date field , i am able to save it 
User-added image
 
Tavva Sai KrishnaTavva Sai Krishna
Hi vsk,

You dont need to convert the text field to date field. the formula function DATEVALUE() will the converts the text value to date value. then use the value in the month() formula field. try the below which will works.
 
CASE(MONTH( DATEVALUE( SLASerialNumber__c)  ),
1, "January",
2, "February",
3, "March",
4, "April",
5, "May",
6, "June",
7, "July",
8, "August",
9, "September",
10, "October",
11, "November",
12, "December",
"None"
)

here in my code SLASerialNumber__C field is text datatype field. you need to convert the value of the field to date format and then pass the value to the month() function. 


Regards,
Sai Krishna Tavva.
Pankaj_GanwaniPankaj_Ganwani
Hi,

Please try with the below mentioned formula
CASE(VALUE(MID(example__c,0,FIND('/',example__c)-1)),
1, "January",
2, "February",
3, "March",
4, "April",
5, "May",
6, "June",
7, "July",
8, "August",
9, "September",
10, "October",
11, "November",
12, "December",
"None"
)

 
DebasisDebasis
Hi 

if your field is a text field and then you can use below formula for month. here you can replace your field inplace of SicDesc. this formula can handel both 03/23/2016 and 3/23/2016 also. 
if( BEGINS(SicDesc, '0'), 
CASE( left(SicDesc,Find("/",SicDesc)-1), 
'01', "January", 
'02', "February", 
'03', "March", 
'04', "April", 
'05', "May", 
'06', "June", 
'07', "July", 
'08', "August", 
'09', "September", 
'10', "October", 
'11', "November", 
'12', "December", 
"None" 
), 
CASE( left(SicDesc,Find("/",SicDesc)-1), 
'1', "January", 
'2', "February", 
'3', "March", 
'4', "April", 
'5', "May", 
'6', "June", 
'7', "July", 
'8', "August", 
'9', "September", 
'10', "October", 
'11', "November", 
'12', "December", 
"None" 
))
User-added image


please do let mek now if it helps you.
Thanks,
Debasis
 
This was selected as the best answer
DebasisDebasis
Hi 
we can optimize above formula also 
if( BEGINS(SicDesc, '0'), 
CASE( left(SicDesc,Find("/",SicDesc)-1), 
'01', "January", 
'02', "February", 
'03', "March", 
'04', "April", 
'05', "May", 
'06', "June", 
'07', "July", 
'08', "August", 
'09', "September", 
"None" 
), 
CASE( left(SicDesc,Find("/",SicDesc)-1), 
'1', "January", 
'2', "February", 
'3', "March", 
'4', "April", 
'5', "May", 
'6', "June", 
'7', "July", 
'8', "August", 
'9', "September", 
'10', "October", 
'11', "November", 
'12', "December", 
"None" 
))


if your field is a text field and then you can use below formula for month. here you can replace your field inplace of SicDesc. this formula can handel both 03/23/2016 and 3/23/2016 also.