Date picker expression help needed (years / months)

Im having a heck of a time trying to figure out how to display the year and months after taking one date and subtracting another.
This formula will give me the year and months but almost as if it were in tenths instead of whole months.
Screen Shot 2021-11-11 at 5.06.32 PM
I tried many others scenarios with no luck
Screen Shot 2021-11-11 at 6.36.14 PM

Ideally Id like to display
“year / months”
If todays date were 11/11/21 and I subtracted 5/11/20 Id like the results to be
“1 / 6”

I just don’t know how to implement the right syntax even after reading about Operators and Comparisons. Can someone help?
Id like it to be in one text element but will split it if need be, appreciate any help.

Hey @luminrabbit :wave:

Thanks for the post and cool idea! This is one of those deceptively difficult things to really nail down. But, it’s possible and it’s been discussed before.

Your original tries are how I’d probably attempt to pull it off as well. One thing to be aware of though is that Bubble doesn’t operate in the typical pemdas order of operations. Instead, it operates literally left to right. To force pemdas, you can use custom states to calculate various parts and then calculate the results of the custom states which will allow you to really control the order.

If you really want to dive into this, another route would be to calculate this value using javascript. You could either use the toolbox plugin or build a custom plugin to run the javascript and there seem to be some promising scripts that might be able to help here.

Sorry to not have a more concrete answer for you! It sounds like you’re working through this correctly though! Custom states will be your friend here along with getting creative about how you do your math to break down the number of days between the two dates.

Give it a try and don’t hesitate to reach out to us directly with any additional questions by emailing Support@Bubble.io

Thank you @Andrew.Vernon very useful information and I really appreciate the links I’ll be diving in for sure!

I’ll post back if I get some positive results. Again thank you!

1 Like