oracle數據庫 hql語句用between and 比較一段時間(帶有時分秒)

1、String hql = "select e from entity e where e.date between to_date('2011-10-1','yyyy-mm-dd hh24:mi:ss') and to_date('2011-11-24','yyyy-mm-dd hh24:mi:ss')";

2、如果只涉及日期,沒有時分秒可以使用tochar,比較字符串進行

     hql = "from CTimesReg r where r.CStation.siteId='"+staNum+"' and to_char(r.observtime,'YYYY-mm-dd') between '"+start+"' and '"+end+"'";

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章