Save Dropdown Input as Date

Hi all,

unfortunately I’m stuck at creating a date using three dropdown menus. My goal is to use three dropdowns (Month, Day, Year) to collect a date from the user. So far so good:

The problem starts with the month dropdown. I would like to create a dropdown in which the User can see the months (January, February etc.). I currently use an option set with all twelve months and the corresponding number behind it. (January → 01). As the Bubble formatting does not allow me to put in numbers that start with “0” as in the January case in a number field, I decided to go with a text field instead. All dropdown combined lead to a result such as 01032022 as a string (text) value.

My questions are:
How can I format this string of numbers into a date?
Is there any easier way to get my desired result without this big workaround?

I also thought about changing the dropdown attribute type of my option set to date, instead of string, but as it looks like, the database only allows me to put the values mm/dd/yyyy etc. at once into the attribute. (January → 01/03/2022 8:00 am) when I only would need the month.

Sorry for this long post. I hope someone can make sense of this problem. In the end, I just would like to create a date using the three dropdown menus.

Many thanks in advance for any hint on how to solve this!

Cheers,
Philipp

One way could be to Create a hidden Input Box with data format “Date” and then keep the initial content as Current Date change date to dropdown day’s value, change month to dropdown month’s value, change year to dropdown year’s value. Then you can pass this Input box’s value to database.

1 Like

Philipp,

Thanks for taking the time to clearly articulate your question. This solution has been noted elsewhere on the forums, however I will present it again here. The most straightforward way to solve this problem is to install the invaluable “Toolbox” plugin. Drop an expression on your page and fill it out similar to below:

This will result in a date type that you can store directly into your database date field via a workflow action. Note, your date will be stored with a 12:00:00 AM default timestamp if you do not specify the time.

1 Like

Hi there,

thanks for your response. Your suggestion worked like a charm! :slight_smile: Thanks a lot!

1 Like

Hi there,

thanks for looking for the solution despite my inability to find it in the forum myself! As I’m rather new to Bubble & JS, I tried to avoid expression so far. I’m definitely going to use this as a lesson learned and will start to have a detailed look at the possibilities with this plugin.

Many thanks!

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