Login Page - Create Account

Support Board


Date/Time: Thu, 13 Mar 2025 16:25:59 +0000



Post From: Compare times, so conditional is only triggered outside of certain time segment

[2022-05-24 15:57:35]
BenjFlame - Posts: 335
Here is a code that will run the conditional only between 11:30 and 11:45.

However, it seems to be triggered outside of this time segment.
Why?



SCDateTime startTime;
  startTime.SetTimeHMS(11, 30, 0);

  SCDateTime endTime;
  endTime.SetTimeHMS(11, 45, 0);


  SCDateTime currentTime;
  currentTime.SetTimeHMS(sc.BaseDateTimeIn[sc.Index].GetHour(), sc.BaseDateTimeIn[sc.Index].GetMinute(), sc.BaseDateTimeIn[sc.Index].GetSecond());

  if (currentTime > startTime && currentTime < endTime)
  {
    SubGraph_Ref_Data.DataColor[sc.Index] = RGB(146,76,112);
  } else
  {
    SubGraph_Ref_Data.DataColor[sc.Index] = RGB(255,255,255);
  }