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.

0 6 477
6 REPLIES 6

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.

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

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 ?

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

Top Labels in this Space