Skip to content

Instantly share code, notes, and snippets.

@javidjamae
Last active September 2, 2015 17:35
Show Gist options
  • Save javidjamae/39c1ebcff8e83370dddb to your computer and use it in GitHub Desktop.
Save javidjamae/39c1ebcff8e83370dddb to your computer and use it in GitHub Desktop.
Select all records created in the last month (MySQL)
select *
from records
where PERIOD_ADD(DATE_FORMAT(NOW(),'%Y%m'), -1) = DATE_FORMAT(created_at,'%Y%m')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment