Format Month as Text into respective Number

Hi all,

I am currently trying to build a dropdown menu in which user’s can select a month. My goal is to merge the result of all three dropdown inputs (Month, Day, Year) into one single date.

As I would like to show the users the months as text (January, February, etc…) I’m not quite sure how I can transform the selected text into a number. Example: January → 01. Does anybody have a good solution for that?

Thanks in advance for your support!

Cheers,
Philipp

Hi there, @philipp.laengle107… if I understand your post correctly, one way you could go is to create an option set that has the month names as the options, and add an attribute (number) to the option set where you assign the number associated with each month. Then, when you need to get a month’s number, refer to the month’s attribute, and you should be good to go.

Hope this helps.

Best…
Mike

Hi Mike,

thanks for your quick response! I actually tried this approach already but I failed at linking the input “January” to the corresponding number in the option set.

If I want to “create my new thing” and I select the Dropdown Menus Input I’m not sure how I can use the text input “January” to refer to the number “01”. Do you - by any chance - know how I could do this?

Cheers

Edit:
My option sets are structured properly: January = 1, February = 2 etc.

If you set up the option set correctly, the month and its corresponding number are already “linked” because the number is just an attribute of the option. Does your option set look like this?

You would click the Modify attributes link next to each option and enter the month number that corresponds to each month.

Thank you for reproducing it! Yes indeed, mine looks like this. I’m trying to display the option set in the dropdown. Like this:

image

Now if I “create a new thing” I would like to fetch the number “01” and not the text. Using the “Dropdown Menu’s value” does only fetch the text input though. Is there any way to convert this or to say “if user selects January, then put 01”

If your option set looks like the one I showed, it should be simple to save a month’s corresponding number to a number field in a data type. You should be able to do that by referring to the dropdown value's month number.

Looks like I just had to adjust a few things on my dropdown in addition to what you said. It works like a charm now. Thank you Mike!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.