var beg_:String = REG_DATE_BEGIN.text; var end_:String = REG_DATE_END.text;
var beg:Date=new Date(beg_.substr(0,4), (parseInt(beg_.substr(4,2))-1), beg_.substr(6,2)); var end:Date=new Date(end_.substr(0,4), (parseInt(end_.substr(4,2))-1), end_.substr(6,2));
if(end.getTime()<beg.getTime()){ Alert.show( "[结束时间]必须大于[开始时间],请重新选择" ); return; }
if((end.getTime()-beg.getTime())> (1000*60*60*24*30)){ Alert.show( "查询时间间隔不能超过1个月" ); return; } |
实际运用 |
var o:Object=getValues(); //拿到值 var beg:String=o.CNT_DATE_B; var end:String=o.CNT_DATE_E; var beg_dt:Date = DateField.stringToDate(beg, "YYYYMMDD"); var end_dt:Date = DateField.stringToDate(end, "YYYYMMDD"); var disTime:Number = Number(end_dt.getTime() - beg_dt.getTime()); var yoy_begin:String=o.YOY_DATE_E; var beg_yoy_begin:Date = DateField.stringToDate(yoy_begin, "YYYYMMDD"); YOY_DATE_B.selectedDate = new Date(beg_yoy_begin.getFullYear(), beg_yoy_begin.getMonth(), Number((beg_yoy_begin.getDate() - disTime/(1000*60*60*24)))); |
11-03