Skip to content

Instantly share code, notes, and snippets.

@gcleaves
Forked from mtrbean/mysql_date_trunc
Last active August 26, 2015 16:12
Show Gist options
  • Save gcleaves/9df6d94ce0062c8eafb7 to your computer and use it in GitHub Desktop.
Save gcleaves/9df6d94ce0062c8eafb7 to your computer and use it in GitHub Desktop.
MySQL date_trunc equivalent
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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment