mybatis 动态sql里面关于时间区间查询的表示方式
2017-07-28 10:06
1671 查看
在项目中查询时间段的sql语句(时间类型为datetime或date):
<if test="pojo.begintime!=null and pojo.begintime!=''">
<![CDATA[ and DATE_FORMAT(tr.summary_date, '%Y-%m-%d')>= DATE_FORMAT(#{pojo.begintime}, '%Y-%m-%d') ]]>
</if>
<if test="pojo.endtime!=null and pojo.endtime!=''">
<![CDATA[ and DATE_FORMAT(tr.summary_date, '%Y-%m-%d') <= DATE_FORMAT(#{pojo.endtime}, '%Y-%m-%d') ]]>
</if>
在项目中查询时间段的sql语句(时间类型为varchar):
<if test="excelImport_date_begin != null and excelImport_date_begin != '' ">
AND
tm.excelImport_date>=#{excelImport_date_begin}
</if>
<if test="excelImport_date_end != null and excelImport_date_end != '' ">
AND
tm.excelImport_date <=#{excelImport_date_end}
</if>
<小于号 < > 大于号>
页面的源码:
<input id="begintime" class="Wdate date_text" type="text"
onclick="WdatePicker({el:'begintime'})" name="qureyBean.begintime"
value="<s:property value="@com.hljw.util.UncDate@shortDate(qureyBean.begintime)" />" />
至<input id="endtime" class="Wdate date_text" type="text"
onclick="WdatePicker({el:'endtime'})" name="qureyBean.endtime"
value="<s:property value="@com.hljw.util.UncDate@shortDate(qureyBean.endtime)" />"
<if test="pojo.begintime!=null and pojo.begintime!=''">
<![CDATA[ and DATE_FORMAT(tr.summary_date, '%Y-%m-%d')>= DATE_FORMAT(#{pojo.begintime}, '%Y-%m-%d') ]]>
</if>
<if test="pojo.endtime!=null and pojo.endtime!=''">
<![CDATA[ and DATE_FORMAT(tr.summary_date, '%Y-%m-%d') <= DATE_FORMAT(#{pojo.endtime}, '%Y-%m-%d') ]]>
</if>
在项目中查询时间段的sql语句(时间类型为varchar):
<if test="excelImport_date_begin != null and excelImport_date_begin != '' ">
AND
tm.excelImport_date>=#{excelImport_date_begin}
</if>
<if test="excelImport_date_end != null and excelImport_date_end != '' ">
AND
tm.excelImport_date <=#{excelImport_date_end}
</if>
<小于号 < > 大于号>
页面的源码:
<input id="begintime" class="Wdate date_text" type="text"
onclick="WdatePicker({el:'begintime'})" name="qureyBean.begintime"
value="<s:property value="@com.hljw.util.UncDate@shortDate(qureyBean.begintime)" />" />
至<input id="endtime" class="Wdate date_text" type="text"
onclick="WdatePicker({el:'endtime'})" name="qureyBean.endtime"
value="<s:property value="@com.hljw.util.UncDate@shortDate(qureyBean.endtime)" />"
相关文章推荐
- myBatis查询某个时间区间数据<if test=""> 如何写判断条件,and 里面的内容怎么写?
- 关于ADO+SQL /Access里面查询日期时间类型语句的一点总结
- Mybatis 使用Mapper接口的Sql动态代码方式进行CURD和分页查询
- 关于oracle-sql-时间区间查询精确到时分秒
- 【Mybatis学习总结六】动态SQL与模糊查询
- 动态SQL模糊查询语句(存储过程)中关于百分号%的处理
- 关于SQL时间类型的模糊查询
- MyBatis动态查询 模糊查询实例sql
- myBatis学习笔记(6)——动态SQL & 模糊查询
- Mybatis 1.动态sql 2.模糊查询
- mybatis中怎么使用like形成动态模糊查询,错误使用CONCAT拼接sql的看过来
- hibernate查询方式:HQL、SQL、Criteria方法、命名、动态分离查询、例子查询
- SQL语句关于时间的查询小心得,希望大家给点意见
- mybatis动态查询之foreach,sql标签查询
- SQL 10 函数 3 日期时间函数 - 2 主流数据库系统中日期时间类型的表示方式
- mybatis动态sql查询语法
- 关于mybatis插件tk.mybatis生成的动态sql语句字段不加``的问题
- Mybatis动态SQL与模糊查询
- MyBatis动态sql中模糊查询
- 工作笔记(一)关于mybatis动态sql,MultipartFile,jsp页面404