Cancel
Showing results for 
Search instead for 
Did you mean: 

Min max value of a list of dates

Pioneer
Pioneer

 

Hi guys,

 

The following code doesn't behave the way I think it should. Maybe it's me but I think it should return a date.

Instead, it returns the number of seconds from 2016/01/01 00:00:00 to 2017/01/03 00:00:00.

The issue is the same with datetimes and for the functions min.

 

var test : list[date]
test.create
test.append(str_to_date("2017/01/01"))
test.append(str_to_date("2017/01/02"))
test.append(str_to_date("2017/01/03"))
print test.max
-- returns 31795200 (368 days)

 

I used to work around this by declaring a datetime variable (whose value was by default 2016/01/01 00:00:00 in Tecnomatix Plant Simulation 13.2 - this value is different in each Plant Simulation release, why??) and by adding this value to the value returned by the max/min function. Yes, this is kind of bothering...

But since Plant Simulation 14, the initial value of a datetime is 1900/01/01 00:00:00.0000 but the min/max function keeps returning a value from 2016/01/01 00:00:00.0000...

 

What do you think?

 

Thanks and have a good day!

1 REPLY

Re: Min max value of a list of dates

Solution Partner Genius Solution Partner Genius
Solution Partner Genius
Hello bpniraci,

Interesting. I've checked the working of the max function and it states that it can only return numerical data types; dates and datetimes do not seem to fall under that category.. It seems that Plant Simulation circumvents this by converting the the value of the date to a real value in seconds by looking at the eventcontroller.date, adding the number of seconds up until that point. This is why you get 368 days, which is also the highest number. In your case I probably would've done the same by adding the start value of the simulation time in order to return a date. But I think that you've established that yourself already.

If you'd like to return the highest value of a list, maybe sorting is an option. After that, simply select the top value of the list. Depending however on how often you do this during the simulation (if at all), this might slow down the runtime of your model.

Best regards,

Nick Peeters
Consultant
cards PLM Solutions

Nick Peeters
Simulation Consultant
www.cardsplmsolutions.com