SQL以时间为查询条件

1.时间格式为String类型(查询所有记录时间     2017-11-03<date<2017-12-03)

if (!Strings.isNullOrEmpty(startDate)) {
    querySql += "and do.enter_date_time >= to_date('" + startDate + "', 'yyyy-mm-dd') ";
}
if (!Strings.isNullOrEmpty(endDate)) {
    querySql += "and do.enter_date_time < trunc(to_date('" + endDate + "', 'yyyy-mm-dd')+1) ";
}
trunc:http://blog.csdn.net/haiross/article/details/12837033

2.后台得到时间格式(endDate = new Date())

querySql += "and do.enter_date_time >= startDate ";
querySql += "and do.enter_date_time <  endDate ";

 

posted @ 2017-12-03 18:15  发福大叔  阅读(5762)  评论(0编辑  收藏  举报