if语句如何写
这个if语句,我不管输入的是一个日期,还是两个日期,它查询的结果都是>开始日期and 小于结束日期的结果(select distinct(进仓编号),进仓时间 from ck_进仓主表 zb inner join ck_进仓明细 mx on zb.进仓主键=mx.进仓主键 and 进仓时间>='2016-1-1 00:00:00'and 进仓时间<=' 23:59:59' order by 进仓编号),我想要的是当我输入一个日期的时候查询结果为大于开始日期或小于结束日期的结果,if语句应该如何改
if (ma1.Success)
{
if (pd.Text == "0")
{
selectSql = "select distinct(进仓编号),进仓时间 from ck_进仓主表 zb inner join ck_进仓明细 mx on zb.进仓主键=mx.进仓主键"
+ " and CONVERT(varchar(100), 进仓时间, 23)=CONVERT(varchar(100), GETDATE(), 23) and 仓库='浦东' " + kh
+ " order by 进仓编号";
Label1.Text = "浦东仓库当日记录";
}
else
{
selectSql = "select distinct(进仓编号),进仓时间 from ck_进仓主表 zb inner join ck_进仓明细 mx on zb.进仓主键=mx.进仓主键"
+ " and CONVERT(varchar(100), 进仓时间, 23)=CONVERT(varchar(100), dateadd(day,-" + pd.Text + ",getdate()), 23) and 仓库='浦东'" + kh
+ " order by 进仓编号";
Label1.Text = "浦东仓库第前" + pd.Text + "天记录";
}
}
else if (ma2.Success)
{
time1 = pd.Text.Trim();
cond = cond + "and 进仓时间>='" + time1 + " 00:00:00'";
Label1.Text = "浦东仓库" + pd.Text + "至今的记录";
if (ma3.Success)
{
time2 = ys.Text.Trim();
cond = cond + "and 进仓时间<='" + time2 + " 23:59:59'";
Label1.Text = "浦东仓库" + pd.Text + "至" + ys.Text + "的记录";
}
}
if (cond != "")
{
selectSql = "select distinct(进仓编号),进仓时间 from ck_进仓主表 zb inner join ck_进仓明细 mx on zb.进仓主键=mx.进仓主键 " + cond + kh +
"order by 进仓编号";
Response.Write(selectSql);
Response.End();
}