Skip to content

Instantly share code, notes, and snippets.

@mtrbean
Last active February 2, 2021 21:18
Show Gist options
  • Save mtrbean/7d3ef773152bc7986864 to your computer and use it in GitHub Desktop.
Save mtrbean/7d3ef773152bc7986864 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')
@RajatGoyal
Copy link

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