$ 0 0 This works for computing a Friday week ending date: CASE WHEN ((any_date - (000101 (DATE))) + 1) MOD 7 = 6 THEN any_date + 6 ELSE any_date + (6 - (((any_date - (000101 (DATE))) + 1) MOD 7 + 1)) END AS fri_week_ending_date
This works for computing a Friday week ending date:
CASE WHEN ((any_date - (000101 (DATE))) + 1) MOD 7 = 6 THEN any_date + 6
ELSE any_date + (6 - (((any_date - (000101 (DATE))) + 1) MOD 7 + 1)) END AS fri_week_ending_date