Applies To:
  • CitectSCADA 4.xx, 5.xx

I have a cicode function that adds one day to any given date:

NewDay(STRING sDate )

   sDate = TimeToStr(DateAdd(StrToDate(sDateWork),86400),2);

I have found one date that will not work with this function, as it will return the same date that I give it. I have noticed that this does not happen if my computer is set to another time zone ( eg. Australia instead of America ).


This is a logic problem caused by the finish of daylight saving in your time zone.

StrToDate() returns the time at 12am on a given date. When 24 hours are added using DateAdd() and then the daylight saving change applied ( -1 hour ) the answer is 11pm on the same day, which is then rounded back to 12am when TimeToStr() is used and so the day will never increment. This only occurs on the one day of the year that daylight saving ends.

A suggested workaround is not to disable daylight saving, but rather to add 12 hours to all StrToDate() results and do all daily calculations at midday, not midnight.