ASP.NET (C#) 通过form 获得了两个输入的日期, 格式为: 03/01/2011 string from = Request.Form["txtbox_PosAuthApproDate_from"];
string to = Request.Form["txtbox_PosAuthApproDate_to"];
DateTime fromd = DateTime.ParseExact(from, "MM/dd/yyyy", null); // 转换后 fromd= 2012/3/01 0:00:00
DateTime tod = DateTime.ParseExact(to, "MM/dd/yyyy", null);将获得的string 转换成datetime 类型 ,然后从数据库Position 表中查找 时间处于 from 和 to 直接的数据 :
sql= " select id, time from POSITION where time between "+fromd+ " and "+ to;报错sql=" select DISTINCT POSITION_NBR , INACTIVE_EFFECTIVE_DT from POSITION where ( INACTIVE_EFFECTIVE_DT between to_date('"+fromd+ "','YYYY/MM/DD HH24:MIS') and to_date('"+to+ "' ,'YYYY/MM/DD HH24:MIS') )" ; 也报错。求指教! 谢谢!
string to = Request.Form["txtbox_PosAuthApproDate_to"];
DateTime fromd = DateTime.ParseExact(from, "MM/dd/yyyy", null); // 转换后 fromd= 2012/3/01 0:00:00
DateTime tod = DateTime.ParseExact(to, "MM/dd/yyyy", null);将获得的string 转换成datetime 类型 ,然后从数据库Position 表中查找 时间处于 from 和 to 直接的数据 :
sql= " select id, time from POSITION where time between "+fromd+ " and "+ to;报错sql=" select DISTINCT POSITION_NBR , INACTIVE_EFFECTIVE_DT from POSITION where ( INACTIVE_EFFECTIVE_DT between to_date('"+fromd+ "','YYYY/MM/DD HH24:MIS') and to_date('"+to+ "' ,'YYYY/MM/DD HH24:MIS') )" ; 也报错。求指教! 谢谢!
sql="select DISTINCT POSITION_NBR , INACTIVE_EFFECTIVE_DT from POSITION where INACTIVE_EFFECTIVE_DT between to_date("+from+ ",'MM/dd/yyyy')
and to_date("+to+" ,'MM/dd/yyyy')" ;