question

Scarlett X avatar image
0 Likes"
Scarlett X asked Scarlett X commented

calculate the difference between two date

I have a table as follow, AAA and BBB are number type. I want to calculate the difference between the values in the AAA and BBB columns, with the unit in days,and write the number of days into the CCC column.

What should I do? Thank you2024-11-20-13-26-08-flexsim-2021.png

FlexSim 21.2.4
datetime
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 Scarlett X commented

First convert the number to a string, which you then use to create a DateTime representation of the date. These can be subtracted from each other and converted to days (datetime is the number of seconds since 01.01.1601, so to convert to days, divide by 86400).

To successfully convert to the datetime class, you have to add a delimiter between the year, month and day. Otherwise the program will interpret the first 1 of 11 to mean "January" and assume the rest is the day, leading to an error.

If you import the dates in another format the conversion might become easier.

date-conversion.fsm


date-conversion.fsm (25.5 KiB)
· 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.

Scarlett X avatar image Scarlett X commented ·

thank you~~~~~~~

0 Likes 0 ·