question

Anggoro P avatar image
0 Likes"
Anggoro P asked Matt Long answered

Call current simulation day name as a variable

Hi, I want to set current day (in day name) for if condition. Is it possible to trace the day name instead of number of days? Note: my simulation time unit is day

Thanks

Choose One
commands
5 |100000

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

Raja Sekaran avatar image
3 Likes"
Raja Sekaran answered Raja Sekaran edited

Hi @Anggoro P

You can capture it using the below code.

string strCurDay = getmodelunit(CURRENT_TIME_STR);
string Curday = strCurDay.substr(13,3); 

Thanks.


dateformat.png (766 B)
5 |100000

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

Matt Long avatar image
3 Likes"
Matt Long answered

There isn't currently a way to get the name of the current day directly, but you can use the getmodelunit() command to get the day of the week, then set the name based upon that. Create a user command to make it easy to call.

string today = getCurrentDay(); 

//getCurrentDay Code
int day = getmodelunit(CURRENT_DAY_OF_WEEK);
Array names = ["Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"];
return names[day + 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.