Get Month Integer by Text Month Name
Question
Application Type
Reactive
Service Studio Version
11.10.13 (Build 39572)

Hi,

I have Text month like Jan, Feb or January, February.

I want its integer value 1 for Jan, 2 for Feb like this. 

Or is there any other way we can convert text "Nov 13, 2021" into date 2021-11-13

Thanks.......

mvp_badge
MVP
Solution

Hello Rohan,

Hope you're doing well.

Unfortunately, there is no built-in action that gives you those values like you pretend, but you can create an action using your own logic.


If you want to avoid JavaScript, just create an action that receives a text as an input parameter and an integer as output:

You may set the Function property of that action set to Yes.

Then you just need to create your own expression to create the date. Something like this should do the trick:

NewDate(TextToInteger(Substr(DateText, 8, 4)), GetMonthNumber(Substr(DateText, 0, 3)), TextToInteger(Substr(DateText, 4, 2)))

where DateText is your text "Nov 13, 2021".


So, for your text "Nov 13, 2021" the ouput of the expression above is 2021-11-13 as you pretend.


Hope that this helps you!


Kind regards,

Rui Barradas

mvp_badge
MVP

Hi Rohan,


You can do this easily with a few JavaScript lines:

 

You can use this as a function and would produce something like this:



OML in attachment.


Kind Regards,

João


ReactiveSandbox.oml

mvp_badge
MVP
Solution

Hello Rohan,

Hope you're doing well.

Unfortunately, there is no built-in action that gives you those values like you pretend, but you can create an action using your own logic.


If you want to avoid JavaScript, just create an action that receives a text as an input parameter and an integer as output:

You may set the Function property of that action set to Yes.

Then you just need to create your own expression to create the date. Something like this should do the trick:

NewDate(TextToInteger(Substr(DateText, 8, 4)), GetMonthNumber(Substr(DateText, 0, 3)), TextToInteger(Substr(DateText, 4, 2)))

where DateText is your text "Nov 13, 2021".


So, for your text "Nov 13, 2021" the ouput of the expression above is 2021-11-13 as you pretend.


Hope that this helps you!


Kind regards,

Rui Barradas

Hello Rohan.

I had a similar situation and my way was like Rui Barradas shares, but instead of all if's I created a static with the months and applied a filter by name or short name, and returns the order.


Regards

Gonçalo Almeida

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.