實現過程如下:
1)請將控制面板中的區域設置日期改為yyyy-mm-dd格式;
2)在組態王應用程序命令語言啟動時輸入如下腳本語言:
SQLConnect( DeviceID, "dsn=歷史;uid=;pwd=");
long month=\本站點$月-1;
long year=\本站點$年;
long day=\本站點$日;
string date1;
if(month==0)
{
month=12;
year=\本站點$年-1;}
date1= StrFromInt( year, 10 );
date1=date1+"-";
date1 = date1 + StrFromInt( month, 10 );
date1 = date1 + "-" + StrFromInt( day, 10);
string whereexpr="日期={#’"+date1+"’}";
SQLDelete( DeviceID, "A", whereexpr);
if (\本站點$月==4||\本站點$月==6||\本站點$月==9||\本站點$月==11)
{
if (\本站點$日==30)
{
day=31;
date1= StrFromInt( year, 10 );
date1=date1+"-";
date1 = date1 + StrFromInt( month, 10 );
date1 = date1 + "-" + StrFromInt( day, 10);
whereexpr="日期={#’"+date1+"’}";
SQLDelete( DeviceID, "A", whereexpr);
}
}
}