Converting Total Minutes to Date Range/Interval

I feel like this should be very easy, but for some reason I am getting stuck when trying to save a value to the database. Essentially, I have an input for Duration, requesting the user input the total duration in total minutes. I have my database field set to date duration (I have also tried date range and simply date), and when creating a create new thing or change thing workflow, I am getting an error from that input saying that the expression evaluates to a number. I understand why it does this - because the 15 is not converted to a date/time format - however I have tried numerous ways of making it alter the data/move it around, etc. yet can not seem to get this into a format that the database will accept for this type of field.

One thing I am considering here, am I overcomplicating this where instead I should just save this as a number instead of a date range/interval altogether, and then have the front end convert this later on when it is needed for date purposes?

Although, I would prefer the format in the database to be already in total time format, that way when I need to call upon that data it can just be converted to total min/hour/day/etc. without additional calculations.

Any input here is greatly appreciated!!

The “duration” data type in Bubble isn’t so much a proper data type as it is an operator that someone really truly messed up. It really means to be an operator that formats a date/ time delta in various representations.

So don’t get spun by that. Just ignore it. It’s completely malfunctional (plugins don’t even support that datatype as, again, it’s not a proper data type).

If you have an input (as you do) where a user is supposed to enter “total time in minutes” just take that submitted number of minutes and save it in your database as a numeric value in milliseconds.

That is, save input’s value * 60000 (which is the number of milliseconds in a minute). Now you have a proper “time delta” (the number of milliseconds in some time span - the resolution of date/times in JavaScript is milliseconds ).

And then, when you want to display that value formatted in some other time units, well, do the math. (Or use a plugin to format it if you can find one that does this properly.)

I have more to say about this most like, but I’m AFK ATM.

1 Like