Mybatis时间段比较

在开始时间和结束时间内的一段时间范围的查询

<if test="timeStart != null and timeStart != ''">
and wfsj &gt;= to_date(#{timeStart}, 'yyyy-MM-dd hh24:mi:ss')
</if>
<if test="timeEnd != null and timeEnd != ''">
and wfsj &lt; to_date(#{timeEnd}, 'yyyy-MM-dd hh24:mi:ss')
</if>

 

查询某个月的

传入的就是“2017-02”这种格式的。

<if test="lastMaintenance !=null and lastMaintenance !=''">
and to_char(last_maintenance,'yyyy-mm') = #{lastMaintenance}
</if>

 

//*************************月份选择*easyui的datebox以月份展示

JSP:

<div class="m-form-cell">
<label for="search-box">维护时间:</label> <input type="text" id="datetime1" >
</div>

JS:
$(function() {
$('#datetime1').datebox({
onShowPanel : function() {// 显示日趋选择对象后再触发弹出月份层的事件,初始化时没有生成月份层
span.trigger('click'); // 触发click事件弹出月份层
if (!tds)
setTimeout(function() {// 延时触发获取月份对象,因为上面的事件触发和对象生成有时间间隔
tds = p.find('div.calendar-menu-month-inner td');
tds.click(function(e) {
e.stopPropagation(); // 禁止冒泡执行easyui给月份绑定的事件
var year = /\d{4}/.exec(span.html())[0]// 得到年份
, month = parseInt($(this).attr('abbr'), 10) + 1; // 月份
$('#datetime1').datebox('hidePanel')// 隐藏日期对象
.datebox('setValue', year + '-' + month); // 设置日期的值
});
}, 0);
},
parser : function(s) {// 配置parser,返回选择的日期
if (!s)
return new Date();
var arr = s.split('-');
return new Date(parseInt(arr[0], 10), parseInt(arr[1], 10) - 1, 1);
},
formatter : function(d) {
var month = d.getMonth();
if(month<=10){
month = "0"+month;
}
if (d.getMonth() == 0) {
return d.getFullYear()-1 + '-' + 12;
} else {
return d.getFullYear() + '-' + month;
}
}// 配置formatter,只返回年月
});
var p = $('#datetime1').datebox('panel'), // 日期选择对象
tds = false, // 日期选择对象中月份
span = p.find('span.calendar-text'); // 显示月份层的触发控件

});

转载于:https://www.cnblogs.com/1023linlin/p/6406469.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值