How to write logic that will sum 2 variables
How to write logic that will sum 2 variables
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?
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: How to write logic that will sum 2 variables
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.