Convert String to YYYYMMDD a date

I want to convert the date which looks like this YYYYMMDD to a date in bubble.
I wanted to do it via regex but I have split it in 3 elements and tried to merge it, but the program cannot confirm arbitrary text to date.

Has anybody converted this in a proper bubble way?
Whole process is done via backend call, so only backend workflows are available.

I’d probably use Luxon for this myself, but you can do it in Vanilla Bubble by defining ANY arbitrary date (rounding down to day if necessary), then changing the Year, Month, and Date accordingly, based on the string.

Just use the first 4 characters to define the year (string: truncated to 4)
The next 2 to define the month (string: truncated from end to 4: truncated to 2)
And the last 2 to define the date (string: truncated from end to 2).

note: I’m pretty sure the Change year/month/date operators always use the users device timezone (regardless of the page timezone settings) - so this will always define the date in the user’s device timezone.

If doing that on the backend, I’m not sure if that will default to UTC or the user running the workflow’s timezone (try it and see), so if you need more control over the defined Timezone I’d definitely use Luxon.

2 Likes

No idea what’s a Luxon, but used your Vanilla Bubble solution.
And it works, as usual with your solutions!

1 Like