March 15, 200223 yr Newbies Is there a simple calculation which can evaluate whether a number is odd or even?
March 15, 200223 yr Yes, it is called Modulo, or MOD for short. It returns the remainder of the integer division of a number. Lets say you have a number field called 'inum'. MOD(inum,2) will return either a 1 or a zero. If you would like the expression to return either 1 or 2, do the following: MOD(inum-1,2)+1. Since this is integer division and really only the remainder, it doesn't make any difference how big inum is: 1001 returns 1, 1002 return 2 (if you use the -1 and +1 expression).
March 15, 200223 yr This calculation can also be used to differentiate odd and even weeks if the number involved is a week(date) calculation. e.g - assuming field week number is week(date) calc Case(mod(week number;2) = 1; "odd week";"even week") This is useful if you have to set startup scripts do things on a fortnightly basis. (Just thought I'd throw it in for anyone who is interested)
Create an account or sign in to comment