Problems with date ranges and missing records
Hi, this is the first time i've posted here. Please treat me gently as I am a relative newcomer to MySQL/PHP.
I have been set a task of finding and totalling the number of items arriving on a a given day, the problem I have is this:
On a day when no items arrive no records are created, and this creates a gap in the results. I need the date to be included and to reflect a value of 0 for that missing day.
At the moment the code I am using is this:
SELECT
DATE_FORMAT(items.DateArrived, '%d/%m') AS Arrived,
COUNT(items.DateArrived) AS TotalArrived
FROM
`returns`
WHERE
(items.DateArrived <= '2005-07-25') AND
(items.DateArrived >= '2005-07-05')
I'm not sure if this can be done in MySQL or whether or not PHP would need to be used. Anyone got any pointers?
James
Subject
Written By
Posted
Problems with date ranges and missing records
July 28, 2005 06:09AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.