Day-of-Week Differences in MySQL and MS SQL Server

Heads-up! In MySQL, WEEKDAY('2012-11-09') = 4 (0-6 starting on Monday), but in SQL Server, DATEPART(dw,'11/09/2012') = 6 (1-7 starting on Sunday). If you’re extracting data from MySQL to load into SQL Server, the correct translation is ((WEEKDAY(date)+1)%7)+1.


Author: Jeff Garretson

Husband, father. Data Scientist. Explorer of Powerful Ideas. Faith and Reason in one package.