Login Page - Create Account

Support Board


Date/Time: Thu, 18 Apr 2024 05:46:36 +0000



[User Discussion] - Convert HMS to MInutes

View Count: 763

[2020-09-13 11:03:52]
Graham - Posts: 44
Struggling to work this out using the SDDateTime() functionality.

How can I convert the total time in HMS to just minutes. SCDateTime can extract any part of the time but I need to convert a variable that could be HMS or just MS to Minutes only.

As an example, if the variable returns 01:56:00 (HMS) what would the code be to convert that to Minutes only, resulting in: 116.

Thanks in advance.
[2020-09-13 12:34:46]
User907968 - Posts: 802
If you already have an SCDateTime variable, for minutes you could use GetTimeInSeconds() / 60
Working with the SCDateTime Variables and Values: GetTimeInSeconds()

int Minutes = dateTime.GetTimeInSeconds() / 60;

If you first need to construct the SCDateTime variable from HMS (or just MS) you could use the appropriate constructor.
Working with the SCDateTime Variables and Values: SCDateTime() Constructors

SCDateTime(int Hour, int Minute, int Second, int Millisecond);

SCDateTime dateTime(H, M, S, 0);

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account