How to convert String data to integer data

Hi, I am trying to convert string(‘Jan’, ‘Feb’, ’Mar’,….) to integer(1,2,3,….) in microflow how to do this, Please help me.  
5 answers

You can use an if-else construction in a variable for this use-case.


Hi Pranaya,

You can use this construction:

if $string = ‘Jan’ then 1
elseif $string = ‘Feb’ then 2
elseif $string = ‘Mar’ then 3

etc etc


Pranaya, probably slightly better then Bob fine solution, since there are on average less:


Sometimes i miss the good old high-coding days.

Or maybe you like this option better:


It first does parseDateTime to your string, making it a datetime. Then throws a formatDateTime to it to get a string, and then converts that string to an integer.

If you use this in a ‘Create variable’-activity, you best add an errorHandler catching the errors if String is not one of the twelve months.

Did a performance test on the three solution options. Bobs solution and the highcode are about the same. Using the functions, makes it about 50% slower.



Did it work Pranaya?


no Bob Boons, Actually I am trying to find data based on filters and In the retrieve data the month wise like from 'Jan' to 'Dec' data should show for that I am using oql query 
"select  SUM(R."UnitsSold")as UnitsSum,
              R."SEGMENT", DATEPART ( MONTH, R."Date") as Months,
              DATEPART ( YEAR, R."Date") as Years
from  Single_Selection_Charts.Realistic R 
where  R."Year" = $Year
GROUP BY R."SEGMENT", Months,Years
order by Months"

I am able to get data but month are integer type like 1,2,3....

this is my domain model 

this is my page 

this is my microflow  calling on search button

this is my output but in months cloumn I need Jan, Feb, … instead of 1,2,3… can help with this