{}

Our Brands

Impact-Company-Logo-English Black-01-177x54

Welcome to the Schneider Electric Website

Welcome to our website.
Search FAQs
How to define custom date range in PME Web 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, 9.0

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:

  1. Each custom entry is defined within the '<TimeDefList>' and is defined within an '<TimeDef>' element
  2. 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
  3. The 'DisplayName' is what will be shown to the end user of the system in the report date range drop-down control
  4. The 'StartDate' identifies the beginning of the time range
  5. 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 a customer wants to add "last hour" as the time period to run the report for only last hour, the user can modify the CustomDateRanges.xml by adding following section at the 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>from Now.AddMinutes(-60)</StartDate>
<EndDate>to Now</EndDate>
</TimeDef>"




Example 2: If a customer wants to add custom date range in order to run the report for "last hour to this hour", the user can modify the CustomDateRanges.xml by adding following section at the 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>from last hour</StartDate>
<EndDate>to 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 the 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 performs 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.

Schneider Electric South Africa

Explore more
Range:
Articles that might be helpful Users group

Discuss this topic with experts

Visit our Community for first-hand insights from experts and peers on this topic and more.
Explore more
Range: