Page 1 of 1
How to write logic that will sum 2 variables
Posted: July 19th, 2012, 9:46 am
by addisababa
I have two variables, Years & Months. I have already written logic to convert the years into months. But now, I would like to add the two to get the total number of months. How should I go about doing this?
Re: How to write logic that will sum 2 variables
Posted: July 23rd, 2012, 9:54 am
by Gregory Martin
In general to sum two variables you simply use the + operator:
numeric monthsSince0AD = YEAR * 12 + MONTHS;
However, you might also want to look at the
cmcode function. This function is useful for operations using dates. Another function
datediff, is good if you want to do date comparisons when a day (in addition to month and year) is available.