Last active
November 10, 2018 17:32
-
-
Save coffeepostal/201542df3e81a84733a840cf79a2c9ff to your computer and use it in GitHub Desktop.
SQL: Selecting Records from Today, the Current Week, and Last Week
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Today */ | |
| SELECT * FROM ('table') WHERE date = CURDATE() | |
| /* Current Week */ | |
| SELECT * price FROM ('table') WHERE YEARWEEK('date') = YEARWEEK(CURDATE()) | |
| /* Last Week */ | |
| SELECT * FROM ('table') WHERE YEARWEEK('date') = YEARWEEK( CURDATE( ) + INTERVAL 1 WEEK ) LIMIT 0 , 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment