Skip to content

Instantly share code, notes, and snippets.

@coffeepostal
Last active November 10, 2018 17:32
Show Gist options
  • Select an option

  • Save coffeepostal/201542df3e81a84733a840cf79a2c9ff to your computer and use it in GitHub Desktop.

Select an option

Save coffeepostal/201542df3e81a84733a840cf79a2c9ff to your computer and use it in GitHub Desktop.
SQL: Selecting Records from Today, the Current Week, and Last Week
/* 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