I have the following query:
SELECT
*
FROM
downloads
WHERE
DATE(downloaded) = CURRENT_DATE;
In other words: I want to select all from downloads from a datetime column called downloaded for today.
Unfortunatly, this query gives an error. I replaced 'DATE' with 'YEAR', 'MONTH', and 'DAYOFMONTH'. And get not errors, but this isn't what I want. And I can't figure out how to use the whole date.
I also need to create queries for selecting records from the day before, the current week, previous week, current month and previous month. Would these use a similar equation to the on above?
Thanks,
Justin.
SELECT
*
FROM
downloads
WHERE
downloaded = CURRENT_DATE;
Mysql Date functions [mysql.com]
I think that because column downloads is a timestamp, and not just a date. Although, I though that MySQL could handel that?
My SQL offers a variety of date/time formats for it's dbs (Date, DateTime, Timestamp, Time, & Year). Which one did you choose for the column "downloaded"? Whatever you chose, the var CURRENT_DATE must match the db format in order for the Query Lisa gave you to work.