conditional decide based on time range

conditional decide based on time range

amy_milesB7Q7X
Advocate Advocate
83 Views
2 Replies
Message 1 of 3

conditional decide based on time range

amy_milesB7Q7X
Advocate
Advocate

[ FlexSim 21.2.3 ]

I want to check to see if I'm on 1st shift or not. I have a decide and I can do Model.time<x hours but that only works for a day. What would be the syntax to say is time between 8am and 4pm so it works if I run the model a week? Or is there a way to designate shifts?

0 Likes
Accepted solutions (1)
84 Views
2 Replies
Replies (2)
Message 2 of 3

Ben_WilsonADSK
Community Manager
Community Manager
Accepted solution

FlexScript's DateTime object has an hour property that can be queried to give you the model's current hour of the day. See the documentation:

FlexScript Class - DateTime (flexsim.com)

So you can get the model's current hour, then use that in your logic:

double currentHour = Model.dateTime.hour; 

You might check out Time Tables as a way to define shifts, along with behaviors that happen at the start and end of the shifts.

0 Likes
Message 3 of 3

amy_milesB7Q7X
Advocate
Advocate

Thanks Ben,got it to work, could not find how to say "between" but just discovered the code builder and was able to do > and < using &&.





0 Likes