c#中oracle的to_date函數(shù)使用方法
更新時間:2014年01月07日 10:05:30 投稿:zxhpj
C#使用參數(shù)傳值方式操作oracle的date字段,主要介紹了oracle的to_date使用方法,大家參考使用吧
例子一,獲取三小時前的記錄
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];
}
例子二,獲取大于當(dāng)前時間的記錄
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 "";
}
相關(guān)文章
解析C#中用Process類終止進(jìn)程,執(zhí)行命令的深入分析
本篇文章是對C#中用Process類終止進(jìn)程,執(zhí)行命令進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05
基于不要返回null之EmptyFactory的應(yīng)用詳解
本篇文章對不要返回null之EmptyFactory進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05

