ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 11-13-2014
Marco Baccalaro Marco Baccalaro is offline
Flexsim Distributor
 
Join Date: Nov 2008
Posts: 8
Downloads: 2
Uploads: 1
Thanks: 10
Thanked 47 Times in 7 Posts
Rep Power: 0
Marco Baccalaro has a spectacular aura aboutMarco Baccalaro has a spectacular aura about
Question Convert Date time into Flexsim seconds number

Is there a simple way to convert a string like: "2014-11-13 13:55:42" into the seconds number used as Start Time written into "MODEL:/Tools/ModelUnits/ModelDateTime/start"?
  #2  
Old 11-13-2014
Marco Baccalaro Marco Baccalaro is offline
Flexsim Distributor
 
Join Date: Nov 2008
Posts: 8
Downloads: 2
Uploads: 1
Thanks: 10
Thanked 47 Times in 7 Posts
Rep Power: 0
Marco Baccalaro has a spectacular aura aboutMarco Baccalaro has a spectacular aura about
Wink My bad solution

I know that it can be converted using the query but I used Flexcript solution.
If needed i write it here:

string Data = "2014-01-01 00:00:00";

int year = stringtonum(stringpart(Data,0,4));
int month = stringtonum(stringpart(Data,5,2));
int day = stringtonum(stringpart(Data,8,2));
int hours = stringtonum(stringpart(Data,11,2));
int minutes = stringtonum(stringpart(Data,14,2));
int seconds = stringtonum(stringpart(Data,17,2));
treenode starttimenode = tonode(getmodelunitnum(START_TIME_NODE));
int anni = year - 1601;
int b_years = 0;
int ii;
for (ii = 1602; ii < year; ii++)
{
if (ii % 400 == 0 || (ii % 100 != 0 && ii % 4 == 0))
b_years ++;
}
int days = b_years * 366 + (anni - b_years) * 365;
switch (month)
{
case 2: days += 31; break;
case 3: days += 59; break;
case 4: days += 90; break;
case 5: days += 120; break;
case 6: days += 151; break;
case 7: days += 181; break;
case 8: days += 212; break;
case 9: days += 243; break;
case 10: days += 273; break;
case 11: days += 304; break;
case 12: days += 334; break;
}
if (month > 2 && (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)))
days ++;
days += (day - 1);
double total = days * 86400 + hours * 3600 + minutes * 60 + seconds;
return total;
The Following User Says Thank You to Marco Baccalaro For This Useful Post:
sagar bolisetti (11-17-2014)
  #3  
Old 11-13-2014
sagar bolisetti's Avatar
sagar bolisetti sagar bolisetti is offline
Flexsim User
 
Join Date: Aug 2013
Location: Hyderabad,India
Posts: 160
Downloads: 145
Uploads: 0
Thanks: 124
Thanked 99 Times in 63 Posts
Rep Power: 150
sagar bolisetti is a jewel in the roughsagar bolisetti is a jewel in the roughsagar bolisetti is a jewel in the roughsagar bolisetti is a jewel in the rough
Default

Hello Marco,

Here is Anthony's post about changing Model units

https://www.flexsim.com/community/fo...22&postcount=3

Tags
conversion, date, time


Thread Thread Starter Forum Replies Last Post
FlexSim 7 Beta release date Ramesh Pinn Product Announcements 1 08-02-2013 07:54 AM
Close and Open ports in Processor every 80 seconds? Gaurav Majumdar Q&A 2 07-17-2013 11:19 AM
Displaying the simulation time with the various date/time formats. Regan Blackett Tips and Tricks 12 11-12-2012 08:01 AM
Modify process time based on number of operators naren nataraj Q&A 4 02-23-2012 09:33 AM
How to use the actual date/time data in Arrival Schedule Mode of Source syseo Q&A 0 10-12-2007 08:22 PM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.