my datefield (
-- Today
artists.onlineDate
) is yyy-mm-dd-- Today
SELECT * FROM artists WHERE DATE(artists.onlineDate) = CURDATE()
-- Yesterday
-- Current Week
-- Current Month
-- Current Year
SELECT * FROM artists WHERE DATE(artists.onlineDate) = DATE(CURDATE())-1
-- Current Week
SELECT * FROM artists WHERE WEEK(artists.onlineDate, 3) = WEEK(CURDATE(), 3)
-- Last Week
SELECT * FROM artists WHERE WEEK(artists.onlineDate, 3) = WEEK(CURDATE(), 3)-1
-- Current Month
SELECT * FROM artists WHERE MONTH(artists.onlineDate) = MONTH(CURDATE())
-- Last Month
SELECT * FROM artists WHERE MONTH(artists.onlineDate) = MONTH(CURDATE())-1
-- Current Year
SELECT * FROM artists WHERE YEAR(artists.onlineDate) = YEAR(CURDATE())
-- Last Year
SELECT * FROM artists WHERE YEAR(artists.onlineDate) = YEAR(CURDATE())-1
0 Comments