当前位置:网站首页>SQL query time period content

SQL query time period content

2022-06-26 05:39:00 Gerald picker Shea

Sql Query time period content

Ideas

  • A certain time period is sent from the front end startTime(String )- endTime(String ) The format is days, excluding hours, minutes and seconds
  • Writing sql Is to add the time format to the corresponding field DATE_FORMAT(crh.create_time,'%Y-%m-%d') Specific date ( Free to define )
  • Query results : for example 2022-6-8 To 2022-6-10 Time period
  • The results include 6-8 0 Point to 6-10 Number 59 branch 59 second

sql

       select * from u_user where 1=1
        <if test="user.endTime != null and user.endTime != '' and user.startTime != null and user.startTime != ''">
            and DATE_FORMAT(crh.create_time,'%Y-%m-%d') &gt;=#{
    user.startTime}
            and
            DATE_FORMAT(crh.create_time,'%Y-%m-%d') &lt;=#{
    user.endTime}
        </if>
原网站

版权声明
本文为[Gerald picker Shea]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260534138427.html