Table of Contents: User and Administrator Guide : Mashup Center 22.214.171.124
The Subtract DateTime Duration function subtracts a datetime interval from a datetime value.
For example, use the Subtract DateTime Duration function to find all entries that have been published during a specific duration of time, such as the last hour, day, week, or month.
The datetime value from which you want to subtract the duration.
For the Input
parameter you can:
- Specify a text value.
- Specify a function value.
- Use a variable to return the value.
- Specify a value from the Input tree.
value must be a datetime value or a string that can be cast to a datetime using one of the default formats. If it is not already a datetime or is not in a default format, first convert it using the Create DateTime function.
The number of years as an integer >= 0. This value to initialized to 0.Month
The number of months as an integer >= 0. This value to initialized to 0.Day
The number of days as an integer >= 0. This value to initialized to 0.Hours
The number of hours as an integer >= 0. This value to initialized to 0.Minutes
The number of minutes as an integer >= 0. This value to initialized to 0.. Seconds
The number of seconds as an integer or decimal >= 0. This value to initialized to 0.0.
Each value must be >= 0. Negative values are ignored.
A new datetime value.
This example shows how to use the Filter operator and the Subtract DateTime Duration function to find all entries that were published in the last four hours.
Assume a feed has a pubDate
element in RSS format:
<pubDate>Wed, 20 May 2009 21:45:17 +0000</pubDate>
Follow these steps to find all entries that were published in the last four hours:
Click OK. The filter condition will be the following.
- Add the Filter operator to the canvas.
- For the Input element, specify the pubDate element in the Input tree:
- Right-click the pubDate value and choose "Date" to cast the value to a Date.
- Select >= for the Comparison.
- For the Value, select the following:
Table 2. Filter condition
|Input element|| Comparison || Value |
| ./pubDate/text() || >= || duration-subtract() |
When the filter condition executes, all datetime values in the feed are converted to the time zone of the JVM on which MashupHub is installed. The datetime value at the start of this example section, Wed, 20 May 2009 21:45:17 +0000, was generated in the Coordinated Universal Time (UTC) time zone. That datetime value is converted to the local time zone, then the comparison to the current time - 4 hours is performed.
Parent topic: Functions : Mashup Center 126.96.36.199
Functions : Mashup Center 188.8.131.52
Supported date formats : Mashup Center 184.108.40.206