How to show last 30 days even if no record exists
Posted: Thu May 06, 2010 4:24 pm
I need to display each day for the last 30 days in my report.
A simple query might give me the following data:
SELECT count(*) FROM orders where orderDate >= '1/1/2010' AND orderDate <= '1/31/2010'
1/1/2010 10
1/4/2010 5
The report displays this data with no problems. However, what I need it to display is this:
1/1/2010 10
1/2/2010 0
1/3/2010 0
1/4/2010 5
Research on the web says that this should be handled in the display logic and not the database. This I agree with.
In C#, I would set up a foreach loop and iterate through a DataView looking for a date. If the date is not found, then print 0, and advance to the next date.
Is it possible to something like this in a Report? I guess I would be overriding the Data band somehow?
A simple query might give me the following data:
SELECT count(*) FROM orders where orderDate >= '1/1/2010' AND orderDate <= '1/31/2010'
1/1/2010 10
1/4/2010 5
The report displays this data with no problems. However, what I need it to display is this:
1/1/2010 10
1/2/2010 0
1/3/2010 0
1/4/2010 5
Research on the web says that this should be handled in the display logic and not the database. This I agree with.
In C#, I would set up a foreach loop and iterate through a DataView looking for a date. If the date is not found, then print 0, and advance to the next date.
Is it possible to something like this in a Report? I guess I would be overriding the Data band somehow?