How to ADD date to date ?

hi

I have field1 date I want when I choose the date in this field1 another field2 = field1 + 2 years

exemple :

fild1 = 15/09/2010

field2 = field1 + 2 years so

field2 = 15/09/2012 for exemple

some one can help me ?

thank you

You have a sys function called mkdate() that allow you to create a date based on fixed numbers. The parameters fo that funcion are : day, month and year number.

So you can use this to create your second date . The function mthofyr() gets the current month of a date, dayofmth() gets the day of a date and year gets a year number of a date.

If you want to sum then both, you can then use the function date2num(field 1) +date2num(field2) (this function gets the number of days so you need to prepare the second date before doing so as explained in the previous step)

and finally you revert the number of days to your date with num2date(the previous sum) .

Hi hakim,

if you want directly u can also add days

15/09/2010+730 it gives 15/09/2012.

thank you

the two methods are good

thank you

Hi Hakim,

You can also make use of “datemthfwd” method in global class

Hi

Which version of AX are you using? I’ve been unable to complete simple formula’s on date fields using the + days feature.

A vendor consultant indicated that is might have been available in a version different to what we are using.

Thanks, Meghan