Support Board
Date/Time: Fri, 09 May 2025 16:01:13 +0000
ACSIL convert string to time
View Count: 3147
[2016-01-27 01:26:38] |
@sstfrederik - Posts: 406 |
I am reading data from an external file, how can I read the a time string and convert it to SC time? thanks |
[2016-01-27 05:01:30] |
|
Give us an example of the time string.
Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2016-01-27 10:40:09] |
@sstfrederik - Posts: 406 |
I read a csv file and tokenize the line. i have an element in an array with string like "09:00pm". do i need to reformat it in the csv first and than do something with atoi or is there a simpler way? thanks. |
[2016-01-27 16:43:44] |
|
Sierra Chart does not have the ability to work with a time format like that. It would have to be something like 09:00 or 09:00:00. There cannot be a.m. or p.m. The hours must be in 24-hour format.
Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2016-01-27 17:05:46] |
@sstfrederik - Posts: 406 |
Thanks. I will reformat the cvs. Which SC function can work with the 24hr format string? I have only seen the string to date function.
|
[2016-01-27 18:57:00] |
|
We are releasing a new version now, 1360, and it will have this new function: double sc.TimeStringToSCDateTime(const SCString& TimeString); Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2016-01-27 19:11:31] |
@sstfrederik - Posts: 406 |
Great! Thanks.
|
[2016-01-28 23:24:29] |
@sstfrederik - Posts: 406 |
Hi, Example code that works. SCString DateString ("2011-12-1"); SCDateTime DateValue; DateValue = sc.DateStringToSCDateTime(DateString); SCString TimeString ("17:00"); SCDateTime TimeValue; TimeValue = sc.TimeStringToSCDateTime(TimeString); SCDateTime DateTime; DateTime.SetDateTime(DateValue, TimeValue.GetTime()); |
[2016-03-03 23:41:20] |
@sstfrederik - Posts: 406 |
The function is correctly supporting yyyy/mm/dd, but does not support dd/mm/yyyy instead it outputs mm/dd/yyyy. Can this be changed? Else be reflected in the documentation. Thanks.
Date Time Of Last Edit: 2016-03-03 23:45:45
|
[2016-03-04 09:27:00] |
|
This function will be in the next release: double sc.DateStringDDMMYYYYToSCDateTime(const SCString& DateString); Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2016-06-27 16:09:04] |
ejtrader - Posts: 688 |
SC Team - Have the following 2 strings and wondering if this can be converted to "SCDateTimeMS" format. DateString='2016-06-26'; // fixed width/digits --- YYYY-MM-DD
TimeString='22:34:03.005'; // fixed width/digits -- HH24:MI:SS.mmm - This includes the milliseconds. Trying to create a variable that can be used as "SCDateTimeMS". Appreciate any input on this. thanks Date Time Of Last Edit: 2016-06-27 16:13:19
|
[2016-06-27 21:32:37] |
ejtrader - Posts: 688 |
If this is not a straight forward conversion - would you please clarify on how many decimals to be used to store DataTimeMS into an external text file and retrieve it so that it can be used as a DateTimeMS variable? Looking to store as a double to string in text file and retrieve it. Thanks |
[2016-06-27 22:10:25] |
|
Use these functions: https://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scTimeStringToSCDateTime https://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scDateStringToSCDateTime Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2016-06-27 23:51:49] |
ejtrader - Posts: 688 |
Thanks SC Team. I tried to use them with SCDateTime/SCDateTimeMS combination - in both the cases I am loosing the millisecond portion from the output. Do I have to any other functions to preserve the millisecond portion? SCString DateString="2016-06-26"; SCString TimeString="22:34:03.005"; //Also tried with SCDateTime in place of SCDateTimeMS - but still missing milliseconds SCDateTimeMS DateValue; DateValue = sc.DateStringToSCDateTime(DateString); SCDateTimeMS TimeValue; TimeValue = sc.TimeStringToSCDateTime(TimeString); SCDateTimeMS DateTime; DateTime.SetDateTime(DateValue, TimeValue.GetTime()); SCString message; message.Format("DateTime: %s", sc.DateTimeToString(DateTime, FLAG_DT_COMPLETE_DATETIME_MS).GetChars()); sc.AddMessageToLog(message, 0); // Got the output as DateTime: 2016-06-26 22:34:03.000 Date Time Of Last Edit: 2016-06-27 23:52:06
|
[2016-06-28 00:47:06] |
|
You need to do it like this: DateTime = DateValue + TimeValue; Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2016-06-28 01:55:40] |
ejtrader - Posts: 688 |
Thanks SC team. For anyone looking for this in the future - this is the resulting code. SCString DateString="2016-06-26"; SCString TimeString="22:34:03.005"; SCDateTimeMS DateValue; DateValue = sc.DateStringToSCDateTime(DateString); SCDateTimeMS TimeValue; TimeValue = sc.TimeStringToSCDateTime(TimeString); SCDateTimeMS DateTime = DateValue + TimeValue; SCString message; message.Format("DateTime: %s", sc.DateTimeToString(DateTime, FLAG_DT_COMPLETE_DATETIME_MS).GetChars()); sc.AddMessageToLog(message, 0); |
To post a message in this thread, you need to log in with your Sierra Chart account: