我使用以下脚本在一个字段中输入日期,向其中添加天数以填充另一个字段。现在我想做相反的事情,输入日期并减去天数以填充不同的字段。
//Script below is the addition
//Field: CTS D/R
var dString = getField("Task Anlys").value;
var dParts = dString.split("-");
var mydate=new Date();
mydate.setDate(dParts[0]);
mydate.setMonth(monthsByName[dParts[1]]);
mydate.setYear(dParts[2]);
//Date + 14 Days * 24 Hours * 60 Minutes * 60 Seconds * 1000 milliseconds
var calNewDays = 14 * 24 * 60 * 60 * 1000;
//Set new date
mydate.setTime(calNewDays + parseInt(mydate.getTime()));
var year=mydate.getYear() + 1900;
var month=mydate.getMonth();
var day=mydate.getDate();
getField("CTS D/R").value = day + "-" + months[month] + "-" + year;`
//Script below is an attempt for subtraction
//Date = 30 Days * 24 Hours * 60 Minutes * 60 Seconds * 1000 milliseconds
var calNewDays = 30 * 24 * 60 * 60 * 1000;
//Set new date
mydate.setTime(parseInt(mydate.getTime() - calNewDays));`