实现过程如下:
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);
}
}
}