【泛微OA】JS计算日期相差年数
<script type="text/javascript">
jQuery(document).ready(function(){
setYearValue();
ModeForm.bindFieldChangeEvent("field14982,field14983",function(obj, id,value){
setYearValue()
});
//***********************
function cuYear(date1Str , date2Str){
var date1 = new Date(Date.parse(date1Str.replace(/-/g, "/")));
var date2 = new Date(Date.parse(date2Str.replace(/-/g, "/")));
var fm=date1.getMonth();
var sm=date2.getMonth();
var dd1=(sm- fm)*30+(date2.getDate()-date1.getDate());
var year = date2.getFullYear() - date1.getFullYear()+dd1/365;
return year;
}
function setYearValue(){
var beginDate = ModeForm.getFieldValue("field14982");
var endDate = ModeForm.getFieldValue("field14983");
var year = cuYear(beginDate, endDate);
ModeForm.changeFieldValue("field14984", {
value: year
});
}
})
</script>
THE END
0
二维码
打赏
海报
【泛微OA】JS计算日期相差年数
<script type="text/javascript">
jQuery(document).ready(function(){
setYearValue();
ModeForm.bindFieldChangeEvent("field14982,field14983",……