1
)在组态王画面中添加两个日期时间控件即:
Microsoft Date and Time Picker Control 6.0
,
控件名称分别为
date1
和
date2
;
2
)在
date1
控件的
CLOSEUP
事件中输入如下命令语言:
long
year1;
long month1;
long day1;
year1=date1.Year;
month1=date1.Month;
day1=date1.Day;
string
查询开始时间
;
if(month1<10&&day1<10)
{
查
询
开
始
时
间
=StrFromInt(year1,
10)+"-"+"0"+StrFromInt(month1,
10)+"-"+"0"+StrFromInt(day1, 10);
}
if(month1<10&&day1>=10)
{
查询开始时间
=StrFromInt(year1,
10)+"-"+"0"+StrFromInt(month1,
10)+"-"+StrFromInt(day1,
10);
}
if(month1>=10&&day1<10)
{
查询开始时间
=StrFromInt(year1,
10)+"-"+StrFromInt(month1,
10)+"-"+"0"+StrFromInt(day1,
10);
}
if(month1>=10&&day1>=10)
{
查询开始时间
=StrFromInt(year1, 10)+"-"+StrFromInt(month1, 10)+"-"+StrFromInt(day1, 10);
}
\\
本站点
\
开始时间
=
查询开始时间
;
3
)在
date2
控件的
CLOSEUP
事件中输入如下命令语言:
long
year2;
long month2;
long day2;
year2=date2.Year;
month2=date2.Month;
day2=date2.Day;
string
查询结束时间
;
if(month2<10&&day2<10)
{
查
询
结
束
时
间
=StrFromInt(year2,
10)+"-"+"0"+StrFromInt(month2,
10)+"-"+"0"+StrFromInt(day2, 10);
}
if(month2<10&&day2>=10)