Free Support Forum - aspose.com

Date with overlap year

Dear all,

I have the cell C5 with the date "2008-12-01".

In cell D5 I want the date of the next month, so in Excel I would use:

=DATE(YEAR(C5);MONTH(C5)+1;DAY(C5))

Note that I'm incrementing the month value. In GridWeb this is not working, it returns "#NUM" when it needs to overlap the year, is this normal?

Best regards,

Nelson Ruivo

Hi,

Following is my testing code which works fine, could you run it.

private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
WebCells cells = GridWeb1.WebWorksheets[0].Cells;
WebCell cell = cells["C5"];
cell.PutValue(DateTime.Now);
cell.NumberType = NumberType.Date1;
cell = cells["C7"];
cell.Formula = "=DATE(YEAR(C5),MONTH(C5)+1,DAY(C5))";
GridWeb1.WebWorksheets.RunAllFormulas();
}
}

Thank you.

Hi,

If you replace:

cell.PutValue(DateTime.Now);

By:

cell.PutValue(new DateTime(2008,12,1));

You will have the error I decscribed.

Regards,

Nelson Ruivo

Hi Nelson,

Thanks, yes, we found the issue. We will figure it out soon.

Thank you.

Hi,

We will fix this issue. Since we now have some urgent work to do first, it will not be availabe recently. So I think that you may use this walkaround:

=if(month(d2)<12, date(year(d2), month(d2)+1, day(d2)), date(year(d2)+1, 1, day(d2)))

Thank you for consider Aspose.