Applies To:
  • CitectSCADA

Summary:
I have a Citect Form in which the operator enters a date and time for data logging

Simply adding the date and time returned from the form does not work on the day daylight saving changes.

FormInput(0,0,"Enter Date ",sDate,10);
FormInput(0,1,"Enter Time ",sTime,10);
IF FormRead(0) = 0 THEN
   iDate = DateAdd(StrToDate(sDate),StrToTime(sTime)));
END

I have found iDate is one hour ahead of the time the operator entered.  


Solution:
This is a logic problem caused by daylight saving.

Citect stores times in seconds from January 1, 1970. When daylight saving occurs at 1:59:59 am and the clocks are wound forward to 3:00:00 am, the time only changes by 1 second.

StrToDate() returns the time at 12am on a given date, before daylight saving is applied. 

The attached Cicode checks if the specified day is a DST change day, then calculates and returns the correct integer for time sDate + sTime. It can also allow you to select either occurance of 1:00 - 1:59 AM when the clock is set back.

See also Q2330.

 


Keywords: