I would like to whish you all a happy new year as this is my first post in 2014!
One of the topics a SCOM administrator has to deal with is reporting. You probably already have created one or more custom reports. Most of the documentation about this is still from SCOM 2007 R2 – which also works for 2012 – and references to basic date/time fields, where you can enter fixed dates.
Here are some authoring examples:
If you have to run a report on a monthly basis you perhaps also want to be able to schedule the report and use relative dates, but that is not possible with standard startdate and enddate parameters.
You need to follow this Technet blog to add a relative date time picker: http://technet.microsoft.com/en-us/library/gg697751.aspx. Specially check the section “Example: Adding a Relative Date Time Picker to the Alert Report“.
The article describes well what needs to be done to change a standard report into a report with relative date time.
Some things I was struggeling with:
- General: You can add all necessary parts through direct XML editing, you only need to know where to add them. => see Sample.Reports.Relative.xml which will help you with that.
- Replace StartDate/Enddate with relative Parameters:
Replace the @Startdate and @Enddate values in the queries with CONVERT(DATETIME, CONVERT(VARCHAR, @StartDate, 101)) and CONVERT(DATETIME, CONVERT(VARCHAR, @EndDate, 101)).
After replacing your startdate and enddate with the new relative parameters, search for your old parameter name and check that you have not used it somewhere, where it was not mentioned in the article!
- Controls in the Parameter block: The article only describes the parameters, which are needed for the relative date time picker, but you also will need controls if you have additional fields, otherwise you only see the date time fields. Here is the list of common report controls.
The Parameter Block is always direct before the report in the XML => see Sample.Reports.Relative.xml
I have also created two sample management packs with one sample report in it which will show the differences.
You can download the sample report management packs here.