zoukankan      html  css  js  c++  java
  • Java mybatis日期比较查询

    public static SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
    public static SimpleDateFormat format1 = new SimpleDateFormat(
    "yyyyMMdd HH:mm:ss");



    /**
    * 得到指定日期的一天的的最后时刻23:59:59
    *
    * @param date
    * @return
    */
    public static Date getFinallyDate(Date date) {
    String temp = format.format(date);
    temp += " 23:59:59";

    try {
    return format1.parse(temp);
    } catch (Exception e) {
    return null;
    }
    }

    /**
    * 得到指定日期的一天的开始时刻00:00:00
    *
    * @param date
    * @return
    */
    public static Date getStartDate(Date date) {
    String temp = format.format(date);
    temp += " 00:00:00";

    try {
    return format1.parse(temp);
    } catch (Exception e) {
    return null;
    }
    }


    <sql id="selectAcShareinfoScoreHistoryVo">
    select share_id,inout_account_type, userName, phone, user_uuid, userName_to, phone_to,
    type, del_flag, create_by, create_time,
    update_by, update_time, score, score_show from ac_shareinfo_score_history
    </sql>

    <select id="selectAcShareinfoScoreHistoryList" parameterType="AcShareinfoScoreHistory" resultMap="AcShareinfoScoreHistoryResult">
    <include refid="selectAcShareinfoScoreHistoryVo"/>
    <where>
    <if test="username != null and username != ''"> and userName like concat('%', #{username}, '%')</if>
    <if test="phone != null and phone != ''"> and phone = #{phone}</if>
    <if test="userUuid != null and userUuid != ''"> and user_uuid = #{userUuid}</if>
    <if test="usernameTo != null and usernameTo != ''"> and userName_to = #{usernameTo}</if>
    <if test="phoneTo != null and phoneTo != ''"> and phone_to = #{phoneTo}</if>
    <if test="type != null and type != ''"> and type = #{type}</if>
    <if test="score != null and score != ''"> and score = #{score}</if>
    <if test="scoreShow != null and scoreShow != ''"> and score_show = #{scoreShow}</if>
    <if test="inout_account_type != null and inout_account_type != ''"> and inout_account_type = #{inout_account_type}</if>

    <if test="createTime != null">
    AND date_format(create_time,'%y%m%d') >= date_format(#{createTime},'%y%m%d')
    </if>
    <if test="updateTime != null">
    AND date_format(#{updateTime},'%y%m%d') >= date_format(create_time,'%y%m%d')
    </if>

    </where>
    </select>

     

    <select id="selectCount" parameterType="NtcodeScaninfo" resultMap="NtcodeScaninfoResult">
    select COUNT(s.scaninfoid) as count
    from ntcode_scaninfo s
    <!-- LEFT JOIN ntcode_antiepidemicpstaff a ON s.scanuuid=a.idcard-->
    LEFT JOIN ntcode_position p ON s.positionid=p.positionid
    LEFT JOIN ntcode_county cou ON p.countyid=cou.countyid
    LEFT JOIN ntcode_town tow ON p.townid=tow.townid
    <where>
    <if test="createTime != null ">
    and date_format(s.create_time,'%Y-%m-%d') = date_format(#{createTime},'%Y-%m-%d')
    </if>
    </where>
    </select>
    再牛逼的梦想,也抵不住我傻逼似的坚持!别在该奋斗的年纪,贪图安逸。 今天多学一些知识,明天开发的速度就更快一下。后天你就会变得更好。
  • 相关阅读:
    [LeetCode]62. Excel Sheet Column Title Excel列序号
    [LeetCode]61. Excel Sheet Column Number Excel列序号
    [LeetCode]60. Rectangle Area矩形面积
    [LeetCode]59. H-Index H指数
    [LeetCode]58. Fraction to Recurring Decimal分数化小数
    [LeetCode]57. Binary Tree Inorder Traversal中序遍历二叉树
    Insert or Merge
    Root of AVL Tree
    是否同一棵二叉搜索树
    List Leaves
  • 原文地址:https://www.cnblogs.com/LowKeyCXY/p/14836000.html
Copyright © 2011-2022 走看看