DateAdd function:
function DateAdd (interval,number,date) {
Switch (Interval.tolowercase ()) {
Case "Y": Return new Date (Date.setfullyear (Date.getfullyear () +number));
Case "M": Return new Date (Date.setmonth (Date.getmonth () +number));
Case "D": Return new Date (Date.setdate (Date.getdate () +number));
Case "W": Return new Date (Date.setdate (Date.getdate () +7*number));
Case "H": Return new Date (Date.sethours (date.gethours () +number));
Case "n": Return new Date (Date.setminutes (Date.getminutes () +number));
Case "S": Return new Date (Date.setseconds (Date.getseconds () +number));
Case "L": return new Date (Date.setmilliseconds (Date.getmilliseconds () +number));
}
}
DateDiff function:
function DateDiff (interval,date1,date2) {
var long = Date2.gettime ()-date1.gettime (); Millisecond difference
Switch (Interval.tolowercase ()) {
Case "Y": Return parseint (Date2.getfullyear ()-date1.getfullyear ());
Case "M": Return parseint ((Date2.getfullyear ()-date1.getfullyear ()) *12 + (Date2.getmonth ()-date1.getmonth ()));
Case "D": Return parseint (LONG/1000/60/60/24);
Case "W": Return parseint (LONG/1000/60/60/24/7);
Case "H": Return parseint (LONG/1000/60/60);
Case "n": Return parseint (LONG/1000/60);
Case "S": Return parseint (long/1000);
Case "L": return parseint (Long);
}
}
JS code for DATEADD and DATEDIFF functions