how to convert simulation time() to weekday as number?

how to convert simulation time() to weekday as number?

support5CRPZ
Advocate Advocate
7 Views
6 Replies
Message 1 of 7

how to convert simulation time() to weekday as number?

support5CRPZ
Advocate
Advocate

[ FlexSim 19.1.2 ]

I am using FlexSim update 2.

I want to know how to convert the simulation running time() to weekday as number not string.

During running FlexSim model, I should get the weekday as number like followed;

Monday => 1, Tuesday => 2, Wednesday => 3....Sunday => 7.

I should use weekly repeated table in patient route and examination distribution like followed;

22010-repeat-exam-area-table.png

I want to know how to convert time() to the repeated weekday number as 1,2,3,4,5,6,7 from Moday or starting 0 time.

0 Likes
Accepted solutions (1)
8 Views
6 Replies
Replies (6)
Message 2 of 7

SCHamoen
Advisor
Advisor
Accepted solution

@Seung Yong Seo

What I usually do is create a global variable called weekdays and make a userevent that fires every 86400 seconds (24 hours) and increase the global variable. When the number becomes 8 I make it 1 again.

Message 3 of 7

support5CRPZ
Advocate
Advocate

Thanks, @steven.hamoen

That's a good idea.

0 Likes
Message 4 of 7

patrick_zweekhorst
Advocate
Advocate

Hi @Seung Yong Seo,

You mention that you are working in FlexSim Update 2, but your version shows FlexSim HC.
If you are working with FlexSim and not HC you can use

Model.dateTime.dayOfWeek

As command the ask for the current day of the week in your simulation. This command does not exist in HC I think.

0 Likes
Message 5 of 7

mischa_spelt
Advisor
Advisor

If you only need the value in one or two places, you could do the calculation on the fly.

time() / hours(24) will give you the amount of days elapsed, when you take this modulo seven you get 0, 1, ..., 6. So if the start of the model is on Monday (day 1), the following should also work:

(int)(time() / hours(24)) % 7 + 1
Message 6 of 7

support5CRPZ
Advocate
Advocate

Thank you @Patrick Zweekhorst.

Yes. I could find the DayOfWeek command in the DateTime class. But 1 is Sunday not Monday. Another conversion script is needed. Thanks anyway.

0 Likes
Message 7 of 7

support5CRPZ
Advocate
Advocate

Thanks @Mischa Spelt.

Perfect!

0 Likes