question

Tee Hiett avatar image
0 Likes"
Tee Hiett asked Jason Lightfoot commented

How do I convert an h:mm:ss string value into minutes?

In the posting, @Felix Möhlmann got me going with DATE_TIME values but I'm having diffficulty implementing his suggestions. In the attached model, TKC Endoscopy 040522_1.fsm.jpg, I am trying to get the time the patient was scheduled to arrive, which is in string h:mm:ss format, into minutes. The String label on the patient is patient.OriginalSchHM in the Arrivals Table. Note that this is not the time of the arrival of the patient but the time the patient was scheduled to arrive, usually much earlier than the patient's arrival time. This is in the activity Assigned Labels.

This converted value in minutes will be put into a patient label patient.OriginalSeqMins

Any help will be welcome.


FlexSim 21.2.4
arrivalsconvert
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Felix Möhlmann commented

What part of my suggestion in the other post are you having trouble with?

Instead of defining a script label in the table you can also read the scheduled time when assigning a label though the source activity.

1664182099251.png

If you want to continue working with the string time, then the way to convert it into a minute value is to use the DateTime constructor again, just the other way around. Pass in the string, define the format and it will give back the date time value. Since the date time is defined is seconds you then have to convert it to minutes.

  1. DateTime dateTime = DateTime(patient.OriginalSeqHMS, "%H:%M:%S");
  2. double minuteTime = dateTime.as(double)/getmodelunit(TIME_MULTIPLE);

Though this will return the number of minutes since midnight, since the date is not specified. As such, the model time and the time in minutes from this conversion will be different if you run the simulation for longer than a day. Which is why I originally suggested to read the values directly from the schedule.


To use the "convert" command, the time string has to be in the format specified in the model settings. For your model that would be "hh:mm:ss AM/PM".

1664182360109.png

You can of course change the setting.

1664182472866.png1664182504606.png

58953-tkc-endoscopy-040522-1_1.fsm


· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.