date = curdate
hi i have a query which should work however it returns nothing.
i have at least 2 entries where completed = No and the date of the task is today.
the code is:
SELECT count(TaskID) AS DueToday, DATE_FORMAT(`TaskDueDate`,'%d.%m.%Y') AS XLABEL FROM tasks
WHERE 'XLABEL' = CURDATE( ) AND Completed = 'No'
however it returns 0
TaskDueDate column in the database is a datetime type that is why i am using dateformat to only display the date of the column as opposed to the date and time.
thanks again
mrhankey
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
i have even tried changing it to this:
SELECT count(TaskID) AS DueToday, DATE_FORMAT(`TaskDueDate`,'%Y-%m-%d') AS XLABEL FROM tasks
WHERE 'XLABEL' = CURDATE( ) AND Completed = 'No'
i think it is the curdate( ) that is causing the issue however i have tried NOW() and still does not work.
mrhankey
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
no still does not return and count of tasks due today.
anything else i can try?
mrhankey
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
thanks for this, XLABEL is not a column in the database, TaskDueDate is the column i am using XLABEL as an alias as i need to trim TaskDueDate column from a datetime type to just the date.
i ran your query however no joy.
thanks again
mrhankey
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
yeah thanks for that, only issue is it returns 0 back where there is definately an entry.
really strange.
mrhankey
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
strange thing is the overdue query i have works fine
SELECT COUNT(tasks.TaskID) AS TasksDue, tasks.TaskDueDate, tasks.Completed
FROM tasks
WHERE tasks.TaskDueDate < CURRENT_DATE() and tasks.Completed = 'No'
i did try changing it to
tasks.TaskDueDate = CURRENT_DATE()
but no joy
mrhankey
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
yeah i am running it on php my admin to test the queries as always prefer to make sure they work there first.
returns no error just duetoday 0
which is definately not right.
mrhankey
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
resolved it now with thanks to a friend:
SELECT count(`TaskID`) AS `DueToday` FROM tasks WHERE DATE_FORMAT(`TaskDueDate`,'%Y-%m-%d') = DATE_FORMAT( NOW(),'%Y-%m-%d') AND `Completed` = 'No'
thanks for your help simplypixie
mrhankey
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
mrhankey
Junior Poster in Training
96 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0