Skip to content

Instantly share code, notes, and snippets.

@eatgrass
Created August 29, 2017 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eatgrass/47cf62a61f7746b10fea1c3b8474a52e to your computer and use it in GitHub Desktop.
Save eatgrass/47cf62a61f7746b10fea1c3b8474a52e to your computer and use it in GitHub Desktop.
select with given interval
-- 1 week ago
SELECT * FROM table WHERE inputtime>DATE_SUB(CURDATE(), INTERVAL 1 WEEK)
-- 1 year ago
select *,YEAR(dateTime) from table where year(dateTime)=year(date_sub(now(),interval 1 year));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment