The Add DateTime Duration function adds a datetime interval to a datetime value.
For example, use the Add DateTime Duration function to find all entries published during the first week of the year.
The datetime value to which you want to add the duration.
For the Input
parameter, choose one of the following actions:
- 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 value in one of the default formats. If the Input
value is not already a datetime value or it 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 Add DateTime Duration function to find all entries that were published during the first week of January 2009.
Assume a feed has a pubDate
element in RSS format:
<pubDate>Fri, 02 Jan 2009 21:45:17 +0000</pubDate>
Follow these steps to find all entries that were published during the first week of January 2009:
- Add the Filter operator to the canvas. You will add two filter conditions.
- The first filter condition searches for all entries >= January 1, 2009:
Click OK. The filter conditions will be the following.
- 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, enter "2009-01-01".
Tip: Because you explicitly cast the Input element to Date, MashupHub will attempt to cast the Value to a date also. This action succeeds if you enter the date value in one of the default formats, such as RSS or Atom. This example entered the date in Atom format.
- Click the plus sign (+) to add the second filter condition. The second filter condition searches for all entries <= January 1, 2009 + 1 week.
- For the Input element, again specify the pubDate element in the Input tree. It should already be marked as a Date.
- Select <= for the Comparison .
- For the Value, select the Add DateTime Duration function.
- For the Input parameter, enter "2009-01-01".
Because the date is in Atom format, which is one of the supported default formats, you do not need to cast it.
- Enter 7 in the Day field. Leave the rest of the fields set to 0.
The parameters in the Add DateTime Duration function dialogue will be the following.
Table 1. Add DateTime function parameters
|Input ||"2009-01-01" |
|Month ||0 |
|Day ||7 |
|Minutes ||0 |
|Seconds ||0.0 |
Table 2. Filter conditions
|Input element|| Comparison || Value |
|./pubDate/text() || <= ||duration-add() |
When the filter condition runs, 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, Fri, 02 Jan 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 January 1 2009 + 7 days is performed.
Parent topic: Builtin functions: imc3
Supported date formats: imc3