It's going to be a challenge, but I think this can be done. Here's the logic that I'm thinking about:
1. Working with a constant that is a week start date where the following is true (I'll call this "StartDate"):
Shift A = Days
Shift B = Afternoons
Shift C = Nights
2. Create a formula using the date from #1 that looks something like this (I'll call this {@StartOfWeek} and assume that a week starts on Sunday):
{MyTable.DateField} - (DayOfWeek({MyTable.DateField}, crSunday) - 1)
3. Create a final formula that will give you the shift:
NumberVar weekMod := DateDiff('w', StartDate, {@StartOfWeek} mod 3;
If {MyTable.Shift} = 'A' then
switch (
weekMod = 0, 'Days',
weekMod = 1, 'Afternoons',
weekMod = 2, 'Nights'
)
Else If {MyTable.Shift} = 'B' then
switch (
weekMod = 0, 'Afternoons',
weekMod = 1, 'Nights',
weekMod = 2, 'Days'
)
Else
switch (
weekMod = 0, 'Nights',
weekMod = 1, 'Days',
weekMod = 2, 'Afternoons'
)
-Dell