Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

Finishing the processing code

Next, we will create the C/AL code to calculate a Fan's age (in years) based on his/her Birth Date and the current WORKDATE. The logic is simple: subtract the Birth Date from the WORKDATE. This gives a number of days. So we divide by 365 (not worrying about Leap Years) and round down to integer years (if someone is 25 years, 10 months and 2 days, we will just consider them 25). In the following code, we did the division as though the result were a decimal field. But because our math is integer, we could have used the simpler expression:

FanAge := ((WORKDATE - "Birth Date") DIV 365);

Finally, we'll write the code to check each Fan record data against our selection criteria, determining if we want to include that fan ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.