Last active
February 2, 2021 21:18
-
-
Save mtrbean/7d3ef773152bc7986864 to your computer and use it in GitHub Desktop.
MySQL date_trunc equivalent
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
DATE_TRUNC('week', now()) === STR_TO_DATE(CONCAT(YEARWEEK(now(), 2), ' Sunday'), '%X%V %W') | |
DATE_TRUNC('month', now()) === DATE_FORMAT(now(), '%Y-%m-01') |
Works fine for year, month but how can you do this with week and quarter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!