Dynamic Hours Selector

Hi Community,

I have an app which helps us manage the flow of vehicles through our yard.
Within, we have an expression that allows us to view our vehicle requirements in the next 6 hours.

The expression is: datetime(now())+“0.06:00:00”

I wonder if anyone knows how I could have this dynamic in a way where my users could select the amount of hours they want the app to look forward to.

Thanks in advance,
Chris.

Duration is a column data type. You can certainly add a column of Type duration and make it a dropdown list that the user can choose the value they wish.

You could make this value choice each time they enter a record, or you could add it to the the UserSettings as a constant value for that user used on each record they enter.

I’d like to build on what @WillowMobileSystems has written by sharing a little of what I’ve learned about how to add times to the current time ( now() ).

One way to do this, which I think is close to what John is indicating, is to have the clients select or type in a number hours. That can be stored as a simple number. It can then be converted into a duration as follows:

concatenate([Number of hours],":00:00")

This expression might be used in a virtual column that is of the “duration” type. You will then be able to add that to the current time in another column.

If you’d like to add these together in one column, I’d suggest the following:

now()+(time(concatenate([Number of hours],":00:00"))-“00:00:00”)

It’s a bit convoluted because time() and -“00:00:00” are required to turn it into a duration that can be added to now(). I learned this trick, by the way, from @Steve.

This would be easier if we had a DURATION() expression (similar to TIME() ), but, alas, we don’t. :frowning:

3 Likes

Thanks, @Suvrutt_Gurjar, for the prompt like. :slight_smile: You did a lot to help me learn this.

1 Like

Actually, I was originally thinking of a human-to-machine translation table. Where you list text value for people to read/use like “1.5 hours”, “30 minutes”, etc and then translate that to the duration equivalent that is used in the expression.

But, I love how this can calculate the duration on the fly. This example will work great if the Duration choices are all in hours. I am not certain of @Chris_Jeal requirement.

How much more complicated does the calculation get if you want to support half-hours, i.e. add 1.5 hours ?

1 Like

I haven’t worked up the half hours yet. I’m sure it’s doable but I’d have to think about that for a while.

Hi all,

So, I got done what I set out to do thanks to the expression above…
I have used a column in a table as a selector and used the following:

now()+(time(concatenate(Time Range[Range],":00:00"))-“00:00:00”)

This works a charm.

Now I just need a workflow triggered by certain times of the day to send the workflow with the snapshot() expression, got this to work manually but still haven’t figured out how to fully automate this yet.

Thanks for your input guys.

Best,
Chris

1 Like