How to filter a date and time

How to filter a date and time

Kauan
Not applicable
46 Views
6 Replies
Message 1 of 7

How to filter a date and time

Kauan
Not applicable

[ FlexSim 21.2.4 ]

Hello !

I have a DBconnector that takes data from SQL Server and pulls it into flexsim. I would like to know if it is possible to filter this table by day and time filter, so that my list is not so heavy.

1679664114820.png


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

luis_gustavo_fsds
Not applicable
Accepted solution

Hello Kauan,

I would need to see your model to know what can be done. For now, I recommend you to use the DateTime functions the way you're using to create columns that will be used to filter, something like SET a Month Column and filter it normally.

0 Likes
Message 3 of 7

Kauan
Not applicable

Hello @Luis Gustavo Freitas

I can't share my file, but I can show the script that pulls the data. I would like to filter the date InputTimestamp.

66334-1679939586385.png

66335-1679939615749.png


0 Likes
Message 4 of 7

luis_gustavo_fsds
Not applicable

Hello Kauan, I've been working in a solution that might be close to what you need.

Here i'm using a query to import the dbConnector by Custom Code. This code compare the date column of the database "Arrivals" (that is in Excel format in this case) whitin the current Model Time and pulls just 1 week of data to GlobalTable1.

Database.Connection dbConn = Database.Connection("db_Historic");

//Query pulls and order the Arrivals in interval of 7 days based on Model DateTime
dbConn.query("SELECT * FROM input_2022 WHERE Arrivals BETWEEN " + string.fromNum(Model.dateTime.excelTime) + " AND " + string.fromNum(Model.dateTime.excelTime + 7) + " ORDER BY Arrivals ASC").cloneTo("GlobalTable1");

By that you can execute this code as many times you need and decrease your model's weight. Depending on your database time format you might need to use other functions of Model.dateTime to adapt the query.


0 Likes
Message 5 of 7

Kauan
Not applicable

Hello Luis, I tried to adapt your code to mine and ended up giving error.

1680022596780.png

1680022622231.png

0 Likes
Message 6 of 7

Jeanette_Fullmer
Community Manager
Community Manager
Your first line has one too many parenthesis I believe and is missing a semicolon.
0 Likes
Message 7 of 7

Jeanette_Fullmer
Community Manager
Community Manager

Hi @kauan pedroso, was Luis Gustavo Freitas's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes