Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Need to return Month/YYYY and sort by it in Report

Author  Topic 

Maxer
Yak Posting Veteran

51 Posts

Posted - 2007-08-20 : 10:54:57


I have a report that is grouped by Month and Year.

So I need it to display:

Jan, 2007
Feb, 2007
Mar, 2007
Apr, 2007
Etc…

AND it needs to be sorted with Jan as the first month and Dec as the last (as if it was 1-12 for months).

Now I can get it to display by taking the month name and concatenating it to the year, but then of course it won’t sort the way I want it to.

Any suggestions on this?

Perhaps I could/should return two values, the first being what I display on the report, and the second being what I sort on as a hidden field? So I could return 200701, 200702, 200703, and so on, to sort on that?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-08-20 : 11:29:05
Convert the date to the first day of the month, and group/order by that to get the correct order:
dateadd(mm,datediff(mm,0,MyDate),0)


CODO ERGO SUM
Go to Top of Page

Maxer
Yak Posting Veteran

51 Posts

Posted - 2007-08-20 : 12:00:14
quote:
Originally posted by Michael Valentine Jones

Convert the date to the first day of the month, and group/order by that to get the correct order:
dateadd(mm,datediff(mm,0,MyDate),0)


CODO ERGO SUM



Interesting, thanks.
Go to Top of Page
   

- Advertisement -