Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > Reporting Services
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Reporting Services SQL Server Reporting Services. Please specify which version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Reporting Services section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 4th, 2008, 09:30 AM
Authorized User
 
Join Date: Aug 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default fill all month in matrix

Hello, I have a matrix with year and month as column headers.
I'm sure you know the problem that when I don't have data to one of the month, I have a "jump" in my matrix (from April its jump to June).

Is there a trick in RS to handle this except by changing my sql query and union it with all the month?

Thanks.

Reply With Quote
  #2 (permalink)  
Old August 4th, 2008, 12:52 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Honestly, the easiest and smartest way to do this is to add a table to your DB that has one record for every year and month.

Something like this:

TABLE: allMonths
    monthYear DATETIME

and then have entries in it such as
    1/1/2008
    2/1/2008
    3/1/2008
    ...
    12/1/2008
    1/1/2009
    ..
    ...
    12/1/2029

And then you do

SELECT AM.monthYear, ...fields from other table[s]...
FROM allMonths AS AM LEFT JOIN yourTable AS T
ON ( Year(AM.monthYear) = Year(T.someDateField)
     AND Month(AM.monthYear) = Month(T.someDateField)
...

I show this in a "Calendar of Events" where I create one record per *day* in order to show all dates in a given range. Here, on my demos page:
http://www.ClearviewDesign.com/Newbie

That's for ASP code, but the principle works the same for PHP, JSP, ASP.NET, etc.
Reply With Quote
  #3 (permalink)  
Old August 5th, 2008, 05:11 AM
Authorized User
 
Join Date: Aug 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Thanks for the reply.

I was afraid that this will be the answer.

Thats the way I know but I hoped that there is a better way in RS to do that with out adding lots of waste rows.

Thank,Roy.

Reply With Quote
  #4 (permalink)  
Old August 5th, 2008, 12:49 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

It's not *that* hard to do it without the extra table, but it's (a) faster, (b) simpler coding, and (c) less error prone to do it this way.

But you *could* do something like this:

<%
For yr = 2007 To 2010 ' or whatever
   Response.Write "<tr>" ' one row per year
   For mn = 1 To 12
       ' one cell per month
       Response.Write "<td>" & MonthName(mn) & " " & yr & "<br/>"
       curDate = #1/1/1900# ' dummy date, in case at EOF
       If Not RS.EOF Then curDate = RS("someDateField")
       Do While Year(curDate) = yr AND Month(curDate) = mn
           ... show data from this record ...<br/>
           RS.MoveNext ' see if another record for this same month
           If RS.EOF Then Exit Do
       Loop
       Response.Write "</td>"
   Next
   Response.Write "</tr>"
Next
%>

Something along those lines.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting month name to month number kalyanykk SQL Server 2005 7 August 19th, 2008 10:37 PM
month calendar bschleusner C# 2005 0 April 13th, 2007 09:46 PM
Sum of sub-matrix of a matrix Gromlok Java Basics 0 March 4th, 2007 03:45 PM
query Current Month, Month+1, Month+2, Month+3 anterior Access 2 September 24th, 2006 08:25 PM
Getting the current month Regornil JSP Basics 1 July 19th, 2004 09:01 PM



All times are GMT -4. The time now is 11:37 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.