Problems / Weekend vs Weekday Sales / Editorial
CASE WHEN dayofweek(sale_date) IN (0, 6) THEN 'weekend' ELSE 'weekday' END
dayofweek
0
6
SUM(amount)
AVG(amount)
day_type
ROUND(..., 2)
weekday
weekend
Every engine numbers weekdays differently, and this is a classic source of silent bugs: DuckDB dayofweek is 0=Sunday..6=Saturday, Spark F.dayofweek is 1=Sunday..7=Saturday, pandas .dt.dayofweek is 0=Monday..6=Sunday, and ISO isodow is 1=Monday..7=Sunday. The same predicate IN (0, 6) that means weekend in DuckDB means Sunday-and-Friday in pandas. When porting date logic across engines, always re-derive the weekend condition from the engine's own convention instead of copying the numbers.
F.dayofweek
.dt.dayofweek
isodow
IN (0, 6)
Solve Weekend vs Weekday Sales yourself →