Last active
April 10, 2017 09:13
-
-
Save niczero/46fd5f65f335458d49f1415938f7f908 to your computer and use it in GitHub Desktop.
Group into 4-week periods (in MySQL)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @day = CURDATE(); | |
SELECT FLOOR(DATEDIFF(DATE_SUB(@day, INTERVAL DAYOFWEEK(@day) DAY), '1970-01-01') / 28) AS FWP | |
-- 1970-01-04 is the start of FWP 0 | |
SELECT FLOOR((TO_DAYS(@day) - TO_DAYS('1970-01-04') + 0.01) / 28) AS FWP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment