Contents: MashupHub User and Administrator Guide : Mashup Center 2.0
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.
The number of months as an integer >= 0. This value to initialized to 0.
The number of days as an integer >= 0. This value to initialized to 0.
The number of hours as an integer >= 0. This value to initialized to 0.
The number of minutes as an integer >= 0. This value to initialized to 0..
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:
- 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:
- Select the Subtract DateTime Duration function.
- For the Input parameter, enter the Current DateTime function
- Enter 4 in the Hours field. Leave the rest of the fields set to 0.
The parameters in the Subtract DateTime Duration function dialogue will be the following.
Table 1. Subtract DateTime function parameters
Table 2. Filter condition
- Click OK. The filter condition will be the following.
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 2.0
Functions : Mashup Center 2.0
Supported date formats : Mashup Center 2.0