Below the piece of code i now use: // Convert current datetime - 120 minutes (= 2 hour) to YYYYmmddUUMMSS FormatDateTime(GetCurrentDate(), GetCurrentTime(), "%Y%m%d%H%M%S", sCurrenDateTime); Substr(FormatDateTime, sCurrentHour, 9, 2); Substr(FormatDateTime, sCurrentDate, 1, 8); Substr(FormatDateTime, sCurrentMinSec, 11, 4); if (number(sCurrentHour) 2) then sForCheck := IncFormatDate(number(sCurrentDate), -1, "%Y%m%d")+string(number(sCurrentHour)+22)+sCurrentMinSec; else sTwoHoursBefore := string(number(sCurrentHour)-2); if Strlen(sTwoHoursBefore) = 1 then sTwoHoursBefore := "0"+sTwoHoursBefore; end; sForCheck := sCurrentDate+sTwoHoursBefore+sCurrentMinSec; end; // Convert datetime from screen (dd-mm-YYYY UU:MM:SS) to YYYYmmddUUMMSS sDateTimeFromScreen := "30-06-2016 23:12:05"; Substr(sDateTimeFromScreen, sScreenYear, 7, 4); Substr(sDateTimeFromScreen, sScreenMonth, 4, 2); Substr(sDateTimeFromScreen, sScreenDay, 1, 2); Substr(sDateTimeFromScreen, sScreenHour, 12, 2); Substr(sDateTimeFromScreen, sScreenMinute, 15, 2); Substr(sDateTimeFromScreen, sScreenSec, 18, 2); sDateTimeFromScreenConverted := sScreenYear + sScreenMonth + sScreenDay + sScreenHour+ sScreenMinute + sScreenSec; // Compare if (number(sDateTimeFromScreenConverted) number(sForCheck)) then RaiseError(CUSTOM_ERROR, "Date/time: "+sDateTimeFromScreen+" this is to old", SEVERITY_ERROR); end;
↧