Skip to content

Instantly share code, notes, and snippets.

@kgaughan
Created November 13, 2012 13:34
Show Gist options
  • Save kgaughan/4065786 to your computer and use it in GitHub Desktop.
Save kgaughan/4065786 to your computer and use it in GitHub Desktop.
Function to get the first day of the month. Why doesn't this already exist in MySQL?!
CREATE FUNCTION FIRST_DAY(dt DATE)
RETURNS DATE DETERMINISTIC
RETURN LAST_DAY(dt - INTERVAL 1 MONTH) + INTERVAL 1 DAY;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment