隐藏

Oracle表时间区间查找

发布:2015/8/7 13:51:13作者:管理员 来源:本站 浏览次数:1428

if (!string.IsNullOrEmpty(model.FROMTIME) && !string.IsNullOrEmpty(model.TOTIME))
            {
                strWhere = strWhere + string.Format(" and FinishTime between  to_date('{0}','yyyy-mm-dd hh24:mi:ss')  and  to_date('{1}','yyyy-mm-dd hh24:mi:ss')  ", model.FROMTIME, model.TOTIME);
            }
            else if (!string.IsNullOrEmpty(model.FROMTIME))
            {
                strWhere = strWhere + string.Format(" and (to_char(FinishTime,'yyyy-mm-dd hh24:mi:ss') >='{0}')", model.FROMTIME);
            }
            else if (!string.IsNullOrEmpty(model.TOTIME))
            {
                strWhere = strWhere + string.Format(" and (to_char(FinishTime,'yyyy-mm-dd hh24:mi:ss')<='{0}')", model.TOTIME);
            }