Created
September 11, 2024 03:49
-
-
Save ducnh1022/7a6192f7b21fbde394f2c901ecc11f57 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
SELECT | |
date_column, | |
CASE | |
WHEN EXTRACT(DAYOFWEEK FROM date_column) = 7 THEN DATE_ADD(date_column, INTERVAL 2 DAY) -- Saturday to Monday | |
WHEN EXTRACT(DAYOFWEEK FROM date_column) = 1 THEN DATE_ADD(date_column, INTERVAL 1 DAY) -- Sunday to Monday | |
ELSE date_column -- Keep the date as is if it's not Saturday or Sunday | |
END AS adjusted_date | |
FROM your_table; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment