Use the Year from DateTime function to return an integer that represents the year component of a datetime string.
For example, if you specify an RSS datetime string of Wed, 30 Apr 2008 13:10:55 EDT
, this function returns 2008
A datetime might include either the code for the timezone, or the hours offset from GMT (Greenwich Mean Time). For example, the datetime Wed, 30 Apr 2008 13:10:55 PST
indicates the Pacific Standard Time (PST) timezone in the United States. This datetime might also appear as Wed, 30 Apr 2008 13:10:55 -0800
, since PST is -8 hours from GMT.
The datetime value that you want to return the year from.
For the Value
parameters, 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.
must be a string and must be in the format of either an RSS or Atom datetime.
The following table shows an example of the Atom and RSS feed datetime formats for Thursday, November 9, 2006, 2:48:40 PM in the Pacific Standard Time (PST) timezone.
|Type of feed||Example datetime format|
|RSS||Thu, 09 Nov 2006 14:48:40 -0800|
Day of the week is optional for the RSS feed format.
The function returns an Integer value that represents the year component of the Value
. For the datetime Wed, 30 Apr 2008 13:10:55 EDT
, this function returns 2008
The function returns the year component of the Value
converted to the timezone of the local JVM (Java™ Virtual Machine), the JVM that MashupHub is using.
If the JVM for MashupHub uses one time zone and the value that you specify uses another timezone, the value that is returned is in the time zone of the local JVM. For example, the JVM that MashupHub is using is set to the -8:00 timezone, the Pacific Standard Time (PST) timezone. If you specify the RSS datetime string Mon, 31 Dec 2007 23:11:55 -1000
a datetime in the Hawaii-Aleutian Standard Time (HAST) timezone, the function returns 2008
, the year value for the datetime in the PST timezone. The datetime Mon, 31 Dec 2007 23:11:55 -1000
in the PST timezone is Tue, 01 Jan 2008 01:11:55 -0800
You can use datetime functions to filter feeds based on date using a Transform operator to create three output elements that contain day, month, and year for each feed entry and a Filter operator to filter the feed based on the output elements. The following example uses a source feed that contains news information and a publication date. The source feed has the following structure:
In the Transform operator, create output elements for the day, month, and year, similar to the following:
|Input tree value||Function||Output element|
|./pubDate||Day from DateTime||pub_day|
|./pubDate||Month from DateTime||pub_month|
|./pubDate||Year from DateTime||pub_year|
In a Filter operator, filter the feed to display entries that have been published after a specific date. For example, to create a filter to display all feed elements starting from May 1, 2008, set the following comparisons and select All
for the conditions that must be satisfied. The following table lists the filter values:
You can use variables to specify any date and not just a fixed date. When the feed is viewed from the catalog or run outside of MashupHub, the user is prompted for the day, month and year values.
Parent topic: Builtin functions: imc3
Supported date formats: imc3