querywrapper设置查询区间
时间: 2023-08-29 17:05:54 浏览: 182
要设置QueryWrapper的查询区间,可以使用le和ge方法。le方法用于设置小于等于的条件,ge方法用于设置大于等于的条件。
例如,假设要查询startTime在某个时间之后并且endTime在某个时间之前的学生记录,可以这样设置queryWrapper:
```
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = sdf.format(date);
QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.ge(Student::getStartTime, format)
.le(Student::getEndTime, format);
```
上述代码将查询startTime大于等于当前时间并且endTime小于等于当前时间的学生记录。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [query wrapper根据时间区间查询](https://blog.csdn.net/weixin_42759398/article/details/130235051)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [QueryWrapper日期查询 日期比较 查询数据库指定日期 分页查询 起止时间 日期相等 只查一天数据](https://blog.csdn.net/tanzongbiao/article/details/128358416)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文