Applies To:
  • CitectSCADA
  • VijeoCitect 

Summary:
There is a cicode function of DateSub() which enables us to subtract any given date with another date we specified. This allows flexibility in manipulation of date in cicode. However, such function does not exist for time. How can we achieve the same functionality to subtract time?

Solution:
DateSub() function can still be used to subtract time since the date/time is being stored in one variable format.

However, minor adjustment is needed.

For example, if you want to subtract 10 seconds from 10:00:00, it can be done as follows:

-----------------------------------

FUNCTION TimeDiff()

INT test1;

test1 = DateSub(StrToTime(“10:00:00”), StrToTime(“00:00:10”));

String1 = TimeToStr(test1,5);

END

-----------------------------------

Note that instead of using StrToDate() function, we must use StrToTime() to convert the string to time format.
 

Keywords:
 time, substract, cicode, date, DateSub, difference

Attachments