spring boot 查询两个时间区间内容(只有一个创建时间字段的前提下)

本文介绍了如何在Spring Boot项目中,仅通过一个创建时间字段,实现查询指定时间段内的数据。通过对日期的处理和SQL查询条件的设定,实现了高效的时间区间过滤功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    <select id="selectSubstituteIntoApplicationList" parameterType="SubstituteIntoApplication"
            resultMap="SubstituteIntoApplicationResult">
        <include refid="selectSubstituteIntoApplicationVo"/>
        <where>
            <if test="account != null  and account != ''">and account like concat('%', #{account}, '%')</if>
            /*判断这两个取值字段不为空的前提下,再查询区间值
            <if test="closeupshoptime != null and setupshoptime != null">
            /jdbcType 是为了给取值变量添加临时sql 字段 类型 并 赋值 判断
            查询订单字段createtime 大等于 startTime 并 小等于 endTime区间的内容*/
            and createtime &gt;= #{startTime ,jdbcType=TIMESTAMP}
            and createtime &lt;= #{endTime,jdbcType=TIMESTAMP}
            </if>
        </where>
    </select>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值