Mike Yearwood
Toronto, Ontario, Canada
Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
>>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.
That's for sure. A person can either work a full week or part of a week. I found one that worked two separate shifts in a single week. Dues are paid for working any part of a week, but only once per week.
>
>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 :).
I thought of that, but Sergey's solution converts a start date to a relative week number (also an arbitrary start) which I can use for each of the start and end dates.
Thanks! :)
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement