c#中oracle的to_date函数使用方法
程序员文章站
2024-02-24 22:30:28
例子一,获取三小时前的记录
public static datatable query()
{
const string ssql = "sele...
例子一,获取三小时前的记录
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 ""; }
上一篇: 字符串与数组
下一篇: 495. Teemo Attacking