var date = new Date();
var v_startDataTime;
var v_endDataTime;
***************************************************************************************
// 上月统计
// 开始-结束:上月开始 -上月结束
if (date.getMonth() + 1 == 1) {
var year = date.getFullYear() - 1;
var d = new Date(year, 12, 0);
var endDay = d.getDate();
v_startDataTime = year + ‘-‘ + ‘12‘ + ‘-‘ + ‘01‘;
v_endDataTime = year + ‘-‘ + ‘12‘ + ‘-‘ + endDay;
} else {
var year = date.getFullYear();
var month = date.getMonth() < 10 ? ‘0‘ + date.getMonth() : date.getMonth();
var d = new Date(year, month, 0);
var endDay = d.getDate();
v_startDataTime = year + ‘-‘ + month + ‘-‘ + ‘01‘;
v_endDataTime = year + ‘-‘ + month + ‘-‘ + endDay;
}
***************************************************************************************
// 本季度
// 开始-结束:本季度开始 -本季度结束
var year = date.getFullYear();
var month = date.getMonth() + 1;
if (month % 3 == 0) {
var month1 = month - 2 < 10 ? ‘0‘ + (month - 2) : month - 2;
var month2 = month < 10 ? ‘0‘ + month : month;
var d = new Date(year, month2, 0);
var endDay = d.getDate();
v_startDataTime = year + ‘-‘ + month1 + ‘-‘ + ‘01‘;
v_endDataTime = year + ‘-‘ + month2 + ‘-‘ + endDay;
} else {
var month1 = (3 * parseInt(month / 3) + 1) < 10 ? ‘0‘ + (3 * parseInt(month / 3) + 1) : (3 * parseInt(month / 3) + 1);
var month2 = (Number(month1) + 2) < 10 ? ‘0‘ + (Number(month1) + 2) : Number(month1) + 2;
var d = new Date(year, month2, 0);
var endDay = d.getDate();
v_startDataTime = year + ‘-‘ + month1 + ‘-‘ + ‘01‘;
v_endDataTime = year + ‘-‘ + month2 + ‘-‘ + endDay;
}
***************************************************************************************
// 上季度
// 开始-结束:上季度开始 -上季度结束
var month = date.getMonth() + 1;
if (month <= 3) {
var year = date.getFullYear() - 1;
var d = new Date(year, 12, 0);
var endDay = d.getDate();
v_startDataTime = year + ‘-‘ + ‘10‘ + ‘-‘ + ‘01‘;
v_endDataTime = year + ‘-‘ + ‘12‘ + ‘-‘ + endDay;
} else {
var year = date.getFullYear();
var mulriple = month % 3 ? parseInt(month / 3) : parseInt(month / 3) - 1;
var month2 = mulriple * 3 < 10 ? ‘0‘ + (mulriple * 3) : mulriple * 3;
var month1 = Number(month2) - 2 < 10 ? ‘0‘ + (Number(month2) - 2) : Number(month2) - 2;
var d = new Date(year, month2, 0);
var endDay = d.getDate();
v_startDataTime = year + ‘-‘ + month1 + ‘-‘ + ‘01‘;
v_endDataTime = year + ‘-‘ + month2 + ‘-‘ + endDay;
}
***************************************************************************************
// 今年
var year = date.getFullYear();
var d = new Date(year, 12, 0);
var endDay = d.getDate();
v_startDataTime = year + ‘-‘ + ‘01‘ + ‘-‘ + ‘01‘;
v_endDataTime = year + ‘-‘ + ‘12‘ + ‘-‘ + endDay;