日期比较大小

SQL

select m.name,t.* from (
    select a.parent_area_id, count(distinct d.dzid)
      from osspad.tb_cablecheck_dtsj d, area a
     where d.areaid = a.area_id
       and d.bdsj >= TO_DATE('2016-12-01', 'yyyy-mm-dd')
       and d.bdsj <= TO_DATE('2016-12-31', 'yyyy-mm-dd')
     group by a.parent_area_id
 ) t,area m where t.parent_area_id=m.area_id

Java

int index = 1;
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  if (StringUtils.isNotEmpty(beginTime)) {
     sql.append(" and trunc(submit_time,'dd')>=?" + index);
     try {
        params.add(sdf.parse(beginTime));
     } catch (Exception e) {
        e.printStackTrace();
     }
     index++;
  }
  if (StringUtils.isNotEmpty(endTime)) {
     sql.append(" and trunc(submit_time,'dd')<=?" + index);
     try {
        params.add(sdf.parse(endTime));
     } catch (Exception e) {
        e.printStackTrace();
     }
     index++;
  }

猜你喜欢

转载自www.cnblogs.com/xyhero/p/375e673c13975d5465ba45cc177e1aaf.html