Adge formula

I need to calculate the adge of my customers, I am using this formula

Adge := FORMAT(DATE2DMY( WORKDATE , 3) - DATE2DMY( Cust.“Birthdate”, 3 ))

This fprmula give me the adge calculated on the year, but I need this calc based on month too.

How can I do It?

I assume that you mean AGE not ADGE?

Do you mean that you want the output to be number of months only, or do you want your result to be something like “7 years and 3 months”?

Luana,

Try the logic in following code:

Input:=010580D; (Your Input Date)
IF DATE2DMY(WORKDATE,1) <DATE2DMY(Input,1) THEN
MonthBorrow:=1;
NoOfDays:=30MonthBorrow+DATE2DMY(WORKDATE,1)-DATE2DMY(Input,1);
IF ((DATE2DMY(WORKDATE,2)-MonthBorrow)<DATE2DMY(Input,2)) THEN
YearBorrow:=1;
NoOfMonths:=12
YearBorrow+DATE2DMY(WORKDATE,2)-DATE2DMY(Input,2)-MonthBorrow;
NoOfYears:=DATE2DMY(WORKDATE,3)-DATE2DMY(Input,3)-YearBorrow;

MESSAGE(’%1 Years %2 Months %3 Days’,NoOfYears,NoOfMonths,NoOfDays);

PS: Thouh in days part, this doesn’t take care of 28,29,30,31 days in a month. Just assuming that no. of days in a month is 30…

check this also

http://www.mibuso.com/forum/viewtopic.php?f=23&t=17548&start=0&hilit=difference+between+2+dates+in+navision

At this moment, I have re age result based on year, only.

So in january of a new year, the formula assumes that the customer have already one more Year.

EX: My birth date is on 10 March, and I have 30 Years old

But, in this case, as we are already on 2012, my age is 31. I don’t want this.

I want, only on 10 March that my age shoul be 31 yars old.

Thanks

Luana, Did you try what I have suggested?

Yes I tried, and seem to be the solution. The problem is My table field for Age is a code Type, and the output calc is ons integer type.

I have already a lot, of records in my table, so I can not change age field Type to Integer.

In C/AL how can I conver one code field Type to a integer Field Type???

I got a solution, thanks for your help.

Thanks Dhan

You are welcome, but what was the solution?