Hi Andrei,
In the meantime, you can use the following script that counts the correct date by using the number of days in the current month:
function Test1()
{
var date = aqDateTime.SetDateElements(2011, 10, 31);
var monthsCount = 1;
if (monthsCount < 0)
{
Log.Message("You cannot specify a negative value");
return;
}
var newDate = AddMonths(date, monthsCount);
Log.Message(date);
Log.Message("+ 1 month");
Log.Message(newDate);
}
function AddMonths(date, monthsCount)
{
var monthsInLastYear = monthsCount % 12;
var yearsCount = (monthsCount - monthsInLastYear) / 12;
var year = aqDateTime.GetYear(date) + yearsCount;
var month = aqDateTime.GetMonth(date) + monthsInLastYear;
if (12 < month) {
year++;
month = month % 12;
}
var daysCount = GetDaysCount(year, month);
var day = aqDateTime.GetDay(date);
if (day > daysCount) {
var daysToEndOfMonth = GetDaysCount(aqDateTime.GetYear(date), aqDateTime.GetMonth(date)) - day;
day = daysCount - daysToEndOfMonth;
}
var hours = aqDateTime.GetHours(date);
var minutes = aqDateTime.GetMinutes(date);
var seconds = aqDateTime.GetSeconds(date);
return aqDateTime.SetDateTimeElements(year, month, day, hours, minutes, seconds);
}
function GetDaysCount(year, month)
{
var daysCount = 31;
if (7 < month)
month--;
if (0 == month % 2) {
if (2 != month) {
daysCount = 30;
}
else {
if (!aqDateTime.IsLeapYear(year)) {
daysCount = 28;
}
else {
daysCount = 29;
}
}
}
return daysCount;
}