c#里怎么查两个datetimepicker之间的值
stringdatemin=dateTimePicker1.Value.Date.ToString("yyyy-MM-dd");stringdatemax=dateTim...
string datemin = dateTimePicker1.Value.Date.ToString("yyyy-MM-dd");
string datemax = dateTimePicker2.Value.Date.ToString("yyyy-MM-dd");
string cmd = "SELECT * FROM L2_PO WHERE (CC_REQ_TIME >#" + datemin + "#) AND (CC_REQ_TIME<#"+ datemax +"#)";
弄不出来,求修改 展开
string datemax = dateTimePicker2.Value.Date.ToString("yyyy-MM-dd");
string cmd = "SELECT * FROM L2_PO WHERE (CC_REQ_TIME >#" + datemin + "#) AND (CC_REQ_TIME<#"+ datemax +"#)";
弄不出来,求修改 展开
展开全部
1.用>=或者<=.否则 连续两天首改毁之间是查不出结者备果的
2.用Between AND,用sql参数,直歼埋接传递dateTimePicker2.Value作为参数值
2.用Between AND,用sql参数,直歼埋接传递dateTimePicker2.Value作为参数值
追问
求代码 谢谢
追答
1.
CDate
2011/8/3
2011/8/1
2011/8/6
2011/8/4
SELECT * FROM test1 WHERE CDate>#8/3/2011# And CDate=或者=@p1 AND CDATE=@p1 AND CDATE=:p1 AND CDATE<=:p2";
展开全部
string dateMin = dateTimePicker1.SelectedDate.Value.ToString("yyyy-MM-dd");
string dateMax = dateTimePicker2.SelectedDate.Value.ToString("yyyy-MM-dd");
string cmdTxt = string.Format("SELECT * FROM L2_PO WHERE CC_REQ_TIME >棚渣 '姿和搏{0}' AND CC_REQ_TIME <迹祥 '{1}' ",dateMin,dateMax);
string dateMax = dateTimePicker2.SelectedDate.Value.ToString("yyyy-MM-dd");
string cmdTxt = string.Format("SELECT * FROM L2_PO WHERE CC_REQ_TIME >棚渣 '姿和搏{0}' AND CC_REQ_TIME <迹祥 '{1}' ",dateMin,dateMax);
追问
还是没有数据 用得是oracle数据库, 数据库里的数据是2011-8-11,再帮我看看 谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询