>Hey all
>
>Without resorting to some looping code, I'm trying to meet a business rule. If a person works different shifts in a single calendar week, they pay dues once for that calendar week.
Now here's an example of ambiguous specs... What goes into the "else" of your "if"?
- person who works same shifts in a single calendar week, they pay what and how many times?
- person who works different shifts in multiple calendar weeks, they pay what and how many times?
- person who works same shifts in a multiple calendar week, they pay what and how many times?
- is it possible that some of them pay dues multiple times for that calendar week?
- is it possible that some of them pay dues once for some other calendar week?
I figure you passed the rule to us as it was passed to you - but you had the additional benefit of live contact to whoever invented the rule, or at least with someone who had the privilege of applying it. For the rest of us programmers, there's just text.
Ah, and BTW, why not create a table of weeks, with starting (and ending?) date(s), and ordinal number (off an arbitrary start)? Then you'd just look how many weeks fit between your two dates, without any need to recalculate anything. And the chance that the weeks table will change while the rest of the app stays are quite slim. If they change the way they define a week, there are larger changes afoot and you'd probably have to change about half of the app :).