csjoz11

导航

MYSQL查询整月

SELECT * FROM team_member WHERE create_time > '2021-08%'
SELECT create_time FROM team_member WHERE DATE_FORMAT(create_time,"%Y-%m") = '2020-08'

   void test1() throws ParseException {
        QueryWrapper<Member> wrapper = new QueryWrapper<>();

//        wrapper.last("order by case when parent_id=0 then id else parent_id END,parent_id,id");
//        wrapper.addFilter
//        wrapper.eq("DATE_FORMAT(start_time,\"%Y-%m\")","2021-07");
        String dateStr="2021-08-11";
        Date userDate = new SimpleDateFormat("yyyy-MM").parse(dateStr);
        String firstStr = new SimpleDateFormat("yyyy-MM").format(userDate);

//        wrapper.eq("DATE_FORMAT(start_time,\"%Y-%m\")",firstStr);
        wrapper.like("start_time",firstStr);
        List<Member> members = memberMapper.selectList(wrapper);
        members.forEach(System.out::println);


    }


posted on 2021-09-26 02:03  csjoz11  阅读(41)  评论(0编辑  收藏  举报