时间:2021-12-27 11:17:01 | 栏目:.NET代码 | 点击:次
例子一,获取三小时前的记录
public static DataTable Query() { const string sSql = "select xh,lsh,name from table where gxsj>to_date(:gxsj,'yyyy-MM-dd HH24:mi:ss')"; OracleParameter[] parameters = {new OracleParameter(":gxsj", OracleType.VarChar, 10)}; parameters[0].Value = DateTime.Now.AddHours(-3).ToString("yyyy-MM-dd HH") + ":00:00"; return DBUtility.DbHelperOra.Query(sSql, parameters).Tables[0]; }
例子二,获取大于当前时间的记录
public static string GetHphm(string sClsbdh) { const string sSql = "select name from table where sj>to_date(:yxsj,'yyyy-MM-dd')"; OracleParameter[] paramters = {new OracleParameter("sj", OracleType.VarChar, 10)}; paramters[0].Value = DateTime.Now.ToString("yyyy-MM-dd"); using (var mReader = DbHelperOra.ExecuteReader(sSql, paramters)) { if (mReader.Read()) { return mReader["name"].ToString(); } } return ""; }