| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2698 人关注过本帖
标题:if语句如何写
取消只看楼主 加入收藏
lukebc
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:3
帖 子:74
专家分:32
注 册:2009-8-18
结帖率:71.43%
收藏
 问题点数:0 回复次数:0 
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();
            }
2017-01-02 19:30
快速回复:if语句如何写
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025321 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved