Calendar control in a Report?
I have a need to create a report that contains a calander, i.e.last month in rows and columns. Any idea on how to accomplish this need?
October 19th, 2007 4:00am

I would look at the Dundas controls... http://www.Dundas.com BobP
Free Windows Admin Tool Kit Click here and download it now
October 19th, 2007 5:00am

Hi. Alternatively you can do it for free...I have done it for several reports. Just create your own calendar using a grid of textbox controls - a gridof 8 rows x 7columnsis sufficient. You can set the top row as a single merged field - to hold the month and year description; put Mon, Tue, Wed etc. in the second row of fields for the days. The remaining 6 x 7 grid you set to be populated from the result set of a query that returns 42 values; either 0 etc. where you want the cell to be blank (i.e. no date) or the date value for the month/year that should be displayed. Just use an IIf style expression to set the field to be blank or not depending on the data. So forSeptember 2007 you would work out and return a result setlike this: 0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,0,0,0,0,0,0 e.g. on the first row Mon - Fri would be blank and the first populated cell would be Sat with a value of 1; as 1st September 2007 was a Saturday. Its not that difficult to knock up a little subreport RDL which takes month and year - then displays a nice looking calendar with the correct date values in the correct positions. You can then use it where ever you want in reports. Regards, Gary.
October 19th, 2007 6:53pm

very cool approach. I never thought of it, but I will give it a try. How is the overhead on this approach?
Free Windows Admin Tool Kit Click here and download it now
October 19th, 2007 9:04pm

Hi, There does not seem to be any serious performance overhead on doing this - we have one report that includes 3 of these style calendars (previous, current and next) and it works great; you just need some SQL that generates your result set of valid days for a year/month. As this is not actually 'getting' any data from any database/table it can run very quickly. If it helps here is the current SQL code we use for generating a 42 field record set of calendar days: -- generate_calender - Gary K Wells - Informa UK - 2007declare @siNumDayssmallintdeclare @siNumCellssmallintdeclare @siStartDaysmallintdeclare @siEndDaysmallintdeclare @siCellsmallintdeclare @siCellValuesmallintdeclare @vchCmdvarchar(512)declare @dtStartDatedatetimedeclare @dtEndDatedatetimedeclare @vchMonthvarchar(30) set @dtStartDate = convert(datetime,'01/' + cast(@siMonth as varchar) + '/' + cast(@siYear as varchar),103)set @siStartDay = datepart(dw,@dtStartDate)set @dtEndDate = dateadd(mm,1,@dtStartDate)set @dtEndDate = dateadd(dd,-1,@dtEndDate)set @siNumDays = datepart(dd,@dtEndDate)set @siEndDay = (@siStartDay + @siNumDays) - 1 set @siNumCells = 42set @siCell = 1set @siCellValue = 1 set @vchCmd = 'select ' while @siCell <= @siNumCellsbegin if @siCell < @siStartDay or @siCell > @siEndDaybeginset @vchCmd = @vchCmd + '-1 as c' + cast(@siCell as varchar)endelsebeginset @vchCmd = @vchCmd + cast(@siCellValue as varchar) + ' as c' + cast(@siCell as varchar)set @siCellValue = @siCellValue + 1end if @siCell <= (@siNumCells - 1)set @vchCmd = @vchCmd + ',' set @siCell = @siCell + 1 end exec(@vchCmd) This expects 2 parameters to be populated @siMonth and @siYear, e.g. 10 and 2007. The calendar cells (i.e. textboxes) then just need to be populated with each of the columns returned as a record set; use an IIf function to leave blank if the value is -1. Hope this helps, Gary.
October 22nd, 2007 6:25pm

VERY COOL thanks !
Free Windows Admin Tool Kit Click here and download it now
October 22nd, 2007 6:28pm

Gary, You've given me hope... Was about to shell out the $ for Dundas to get a Month calendar report. I'm attempting to geta report to look just like the print preview when you look at outlook calendar in Month view. Any thoughts on getting each meeting/event as an item for each day? Have to get the recurring one's working also... fun.... THanks anyway for posting the code.. Darren
November 10th, 2007 12:38am

Very useful thanks! I was looking for a start on building a calendar in ssrs 2008 and this was perfect!
Free Windows Admin Tool Kit Click here and download it now
November 30th, 2010 10:05am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics