美文网首页
mybits 根据指定日期查询 当天 周 月 数据条件过滤

mybits 根据指定日期查询 当天 周 月 数据条件过滤

作者: 记忆心态 | 来源:发表于2019-06-28 10:30 被阅读0次

mybits 根据指定日期查询 当天 周 月 数据条件过滤

<choose>

--指定日期当天

  <when test="classType == 1 and  dateStr!=null and dateStr!=''">

    and date(create_date) = date(#{dateStr})

  </when>

--指定日期当周

  <when test="classType == 2 and  dateStr!=null and dateStr!=''">

    AND DATE_FORMAT(create_date,'%Y-%m-%d') &gt;=subdate(#{dateStr},if(date_format(#{dateStr},'%w')=0,7,date_format(#{dateStr},'%w'))-1)     and subdate(#{dateStr},if(date_format(#{dateStr},'%w')=0,7,date_format(#{dateStr},'%w'))-7) &gt;= DATE_FORMAT(create_date,'%Y-%m-%d')

  </when>

--指定日期当月

  <when test="classType == 3 and  dateStr!=null and dateStr!=''">

    AND DATE_FORMAT(create_date, '%Y%m') = DATE_FORMAT(#{dateStr}, '%Y%m')

  </when>
  </choose>

相关文章

网友评论

      本文标题:mybits 根据指定日期查询 当天 周 月 数据条件过滤

      本文链接:https://www.haomeiwen.com/subject/wcxscctx.html