SharePoint Designer 2010 MOD function

I am working out some log where employees can request vacation, sick time, etc. One validation rule requires that you must always request time off in 4 hour intervals.  This is easy enough to do – use a modulo function.  Modulo function tells you the remainder in division.  If there is no remainder, modulo is zero, otherwise, it’s whatever is left.  For instance, 8 mod 4 = 0 (8 / 4 = 2 with no fraction).  On the other hand, 8 mod 5 is 3.

I needed to do this once with SPD 2007 once upon a time and I actually ended up using an InfoPath form to solve, so it was handled on the front end at the time.  In the current case, there may be an InfoPath form in the picture, but that’s not clear yet.  So, I was working out a technique to ensure that time requests are always in 4 hour increments.  I was going to do the math, save it in a string and then do some substring stuff. 

I pull up SPD 2010 and to my surprise (and a little embarrassment) there is a modulo function already:

image

I am once again pleasantly surprised that something I needed is already there out of the box.  It does seem like a weird function for Microsoft to include in the mix.  It has a sort of “this is easy, so let’s throw it in” feel to it.  I sympathize with that, as I do it myself all the time.  This CodePlex project has a bunch of little functions that result from the ItsEasy principle.  At the same time, Microsoft continues to support evidence the “95% of the way” effect with the product.  They implement the Mod function, but not the round function, for instance.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

One thought on “SharePoint Designer 2010 MOD function

  1. Pingback: Tweets that mention SharePoint Designer 2010 MOD function « Paul Galvin's SharePoint Space -- Topsy.com

Leave a Reply

Your email address will not be published. Required fields are marked *