Technical FAQs

Ask a Question

How to define custom date ranges in PME Reports

Issue
A user would like to specify a reporting date range different from those included by default.

Product Line
Power Monitoring Expert 8.x

Environment
PME 8 Web Applications Reporting

Resolution

PME 8 added the ability to define custom date ranges for the standard date range selector in Web Reporter.  The custom date ranges are defined in an XML file.

Finding the Custom Date Range File

Navigate to [PME Install Dir]\web\bin and find CustomDateRanges.xml

*Warning: Take backups of any files prior to modifying them. Ensure the backups are in a location that will not be overwritten (i.e. the Desktop). ​

Defining a Custom Date Range
Within CustomDateRanges.xml:

  • Each custom entry is defined within the '<TimeDefList>' and is defined within an '<TimeDef>' element.
  • Each defined range must have a unique ID and it must be greater than 1000 to indicate to the PME system that this is a custom defined Date Range.
  • The 'DisplayName' is what will be shown to the end user of the system in the report date range dropdown control.
  • The 'StartDate' identifies the beginning of the time range
  • The 'EndDate' identifies the end of the time range
 
Once you have added a new TimeDef block and saved the XML file it will appear in the drop down in the data selector in Web Reporter.

For Example: If customer wants to add "last hour" as time period to run report for only last hour, user can modify the CustomDateRanges.xml by adding following section at very end of the XML file: 

               " <TimeDef>
                 <ID>1029</ID>
                <DisplayName ResourceAssembly="Reporting.Enhanced.Processor" ResourceFile="SchneiderElectric.Reporting.Enhanced.Processor.Resources.CustomDateRangeResources" ResourceKey="Last Hour">Last Hour</DisplayName>
                <StartDate>Now.AddMinutes(-60)</StartDate>
                <EndDate>Now</EndDate>
                </TimeDef>"




Example 2: If customer wants to add customer date range in order to run report for "last hour to this hour",  user can modify the CustomDateRanges.xml by adding following section at very end of the XML file: 

                "<TimeDef>
                       <ID>1030</ID>
                       <DisplayName ResourceAssembly="Reporting.Enhanced.Processor" ResourceFile="SchneiderElectric.Reporting.Enhanced.Processor.Resources.CustomDateRangeResources" ResourceKey="Last Hour offset">Last                           Hour offset</DisplayName>
                       <StartDate>last hour</StartDate>
                       <EndDate>this hour</EndDate>
                </TimeDef>" 




NOTE: Please review below for basic information which can be used to configure your custom date range. 

Date Range Expression Syntax
Date ranges are specified by english-like phrases that mimic natural language. Following is a quick sample of what it looks like,
  • today
  • yesterday
  • last 7 days
  • last month
  • this year
  • next week
Basic Ranges and Counts
There are several predefined single word ranges that can be used on their own, or can appear in other expressions:
  • minute[s]
  • hour[s]
  • day[s]
  • week[s] month[s]
  • year[s]
  • dayofmonth
  • <count>::=  any numeric value written as digits, eg. (0,1, 123,-17), or any written out english word for the numbers 1 through 12 (‘one’, ‘two’,…)
  •  
Times Relative to Now
Predefined Intervals
  • today
  • tomorrow
  • yesterday
Current Period
  • last < timeDimensionName>
  • this < timeDimensionName>
  • next < timeDimensionName>
Ex: this week, next year, last hour
Stretch Including Now
  • [the] next  <count> <timeDimensionName>
  • [the] last <count> <timeDimensionName>
  • Ex: “the next 3 weeks” goes from the start of the current week to the end of Saturday three weeks from now, so it can be up to 28 days.  “the last two hours” includes all of the current hour, plus the two hours prior to that.  You may add the final ‘s’ for plural time dimensions for readability but they are optional
Offset From Now
  • <count> <timeDimensionName> ago
  • <count> <timeDimensionName> from now
Ex: “22 hours ago” If it’s 4:50 pm, 22 hours ago is 6pm to 7pm yesterday.
Years
  • year.nnnn
Ex: “year.2004” runs from midnight Jan 1 (start of day) to end of day dec 31.
Indexing and Filtering One Time Relative to Another
  • nth timeDimensionName>  [=<value>] {before | after } <timePoint>
  • nth  < timeDimensionName>  [=<value>] {before | after of in} <date range>
Where
  • nth is a number followed by ‘st’ ‘nd’ ‘rd’ or ‘th’, like 1st, 2nd, 53rd, 99th etc, or an English number-word ‘first’ through ‘fourth’.
  • <timePoint> is any expression that evaluates to a single point in time (see below)
  • <daterange> is any other date range expression
  • <value> is the name of a day of week, or month, or the number for a minute or hour for filtering
  • Examples:       
    • 1st day=sunday of this year       
    • 7th week before startof(this month)       
    • second dayofmonth=20 before now
 
Relative Offsets Within Intervals
These are expressions like ‘this week last year’ which find the index of one time (this week) within another (this year) and then use that offset to move around in a different but related period (last year).You make them by simply putting two of the first four kinds of expressions listed above under ‘Times relative to now’ beside each other: { time relative to now } { time relative to now } Samples make this clearer:
  • This week last year
  • This month last year
  • This week last month
  • This month 3 years ago
  • This day last year
  • Next week last year
  • two weeks ago last year
 
Explicit time ranges
If none of the above combinations gives you what you want, you can combine them by explicitly naming the start and end of the period that you want separately.
  • from (<timePoint1> | <timeInterval1) to (<timePoint2> | <timeInterval2)For the dates in the ‘from’ and ‘to’ clauses, you can either use a single time point (described below) or any other valid time interval expression.  If you use an interval expression, the start of the interval is used in the ‘from’ and the end of the interval is used in the ‘to’.  This is effectively a shorthand for  “from Startof(<timeInterval1>) to Endof(<timeInterval2>)”.
  •  
  • Examples:
  • from Startof(second dayofmonth=20 before now) to Startof(first dayofmonth=20 before now)
    (this reproduces the ‘last 20th to 20th’ functionality of the previous implementation)
  • from startof(next hour) to endof(4 hours from now)
    (this reproduces the ‘next 4 hours’ functionality of the previous implementation)
  • from 3 weeks ago to 2 weeks ago
    from makedate(2009,06,01) to now
  • If you wanted to view data from a particular date onward, you could always have a predefined date range in the list.  makedate() creates a single time point that can participate in expressions
Time Points
  • startof( <any date range expression> )
    Picks the start time of the specified date range
  • endof( <any date range expression> )
    Picks the end time of the specified date range
  • makedate( yy, mm, dd, [, hh, mm, ss])
    Makes an explicit date, like makedate(2009, 7, 13).
  • now
    The current time, to the second
  • eternity 
    Maximum possible date

 


Example of implementation: Adding a "Last 3 Months" relative date range

Add the blue highlighted entry to the bottom of the CustomDateRange.xml file then perform an iisreset by executing iisrest in a run window.

.....
  <TimeDef>
    <ID>10128</ID>
    <DisplayName ResourceAssembly="Reporting.Enhanced.Processor" ResourceFile="SchneiderElectric.Reporting.Enhanced.Processor.Resources.CustomDateRangeResources" ResourceKey="LastTwentyEight">Last 28th to 28th</DisplayName>
    <StartDate>from 28th day in last month</StartDate>
    <EndDate>to 28th day in this month</EndDate>
  </TimeDef>
    <TimeDef>
    <ID>10129</ID>
    <DisplayName>Last 3 Months</DisplayName>
    <StartDate>Now.AddMonths(-3)</StartDate>
    <EndDate>Now</EndDate>
  </TimeDef>

</TimeDefList>


With this setup the report will return data from the previous 3 months through the date the report was generated.

Alternatively you could configure the reporting range as follows:

.....
  <TimeDef>
    <ID>10128</ID>
    <DisplayName ResourceAssembly="Reporting.Enhanced.Processor" ResourceFile="SchneiderElectric.Reporting.Enhanced.Processor.Resources.CustomDateRangeResources" ResourceKey="LastTwentyEight">Last 28th to 28th</DisplayName>
    <StartDate>from 28th day in last month</StartDate>
    <EndDate>to 28th day in this month</EndDate>
  </TimeDef>
    <TimeDef>
    <ID>10129</ID>
    <DisplayName>Last 3 Months</DisplayName>
    <StartDate>from startof(Last 3 Months)</StartDate>
    <EndDate>to endof(Last Month)</EndDate>
  </TimeDef>

</TimeDefList>

Or

.....
  <TimeDef>
    <ID>10128</ID>
    <DisplayName ResourceAssembly="Reporting.Enhanced.Processor" ResourceFile="SchneiderElectric.Reporting.Enhanced.Processor.Resources.CustomDateRangeResources" ResourceKey="LastTwentyEight">Last 28th to 28th</DisplayName>
    <StartDate>from 28th day in last month</StartDate>
    <EndDate>to 28th day in this month</EndDate>
  </TimeDef>
    <TimeDef>
    <ID>10129</ID>
    <DisplayName>Last 3 Months</DisplayName>
    <StartDate>Last 3 Months</StartDate>
    <EndDate></EndDate>
  </TimeDef>

</TimeDefList>


With this setup, the reporting range will cover the previous three months before when the report was generated.


This configuration will add a new relative range "Last 3 Months" in the Reporting Period selector.

Was this helpful?
What can we do to improve the information ?