| 1:35 pm on Sep 27, 2005 (gmt 0)|
That's a tricky/juicy puzzle.
On first thought, without much thought, here's my solution:
one table with nothing but dates - 1 column with as many dates as you want to compare. This table can be dynamic, rolling over every month with new dates, etc.
Then, an outer join to the data table. If there is no data in the data table, you'll still get a row for each date.
You could even create a temp table on the fly in your code with the dates, then DROP it after your outer join returns results.
| 11:40 am on Sep 28, 2005 (gmt 0)|
Hmm, think I'll try the solution with a table of dates. Thanks!
| 11:44 am on Sep 28, 2005 (gmt 0)|
An alternative way of doing this is to handle the date range in the presentation code. I've done a similar thing with an event calendar.
1. Open your query recordset (with dates missing)
2. Begin simple loop to display the date range (200509 to 200602)
3. Check whether the current record's date value is the same as the current loop date value:
- If [recordset date] = [code loop date], display the recordset value and move to the next record.
- If not, just display blank/zero/whatever
| 2:21 pm on Sep 28, 2005 (gmt 0)|
I thought of doing that first, but since I'm processing my data in XSLT I thought it might be more efficient to have the data be "correct". But I'll look into looping and such in the php code that generates the XML file instead.
| 12:31 pm on Sep 29, 2005 (gmt 0)|
I dont know if anyone has mentioned this already ,sorry.. but the solution is a pivot/crosstab
| 7:41 am on Sep 30, 2005 (gmt 0)|
aspdaddy: Care to give me some more info on it?
| 2:02 pm on Sep 30, 2005 (gmt 0)|
I am assuming you want to create a column in the output for each day? I do like the suggestion to OUTER JOIN a Dates table. The crosstab will work too - see below.
There is some decent free code for SQL2K for Dynamic Cross-Tabs/Pivot Tables [sqlteam.com]. The The Rozenshtein Method [stephenforte.net] is a common technique if you know how many columns you need.