Skip to content

Instantly share code, notes, and snippets.

@bjpeterdelacruz
Created May 8, 2018 20:46
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 bjpeterdelacruz/1960c5201e564a96b9f0fc0a0421a380 to your computer and use it in GitHub Desktop.
Save bjpeterdelacruz/1960c5201e564a96b9f0fc0a0421a380 to your computer and use it in GitHub Desktop.
Find data for one day only in MySQL
-- Find data for May 8, 2018 only.
-- WRONG
SELECT * FROM inbox WHERE datetime >= date('2018-05-08') and datetime < date('2018-05-08');
-- Correct
SELECT * FROM inbox WHERE datetime >= date('2018-05-08') and datetime < date('2018-05-08') + interval 1 day;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment