Extract Date
This data converter finds and extracts a date. The extracted date is output in the standard date format.
Note: If a date that is already in the standard date format should be reformatted, use the Format Date data converter instead.
Properties
The Extract Date data converter is configured using the following properties:
- Basic
- Formats
-
The date formats, in the order that they should be tried. The first date format that matches the input will be applied. If none match, the data converter will generate an error. Click the '+' sign at the top of the list to add a new date format. The data converter supports two kinds of date formats: Format patterns and relative dates. Format patterns allow specification of a date using patterns like MM/dd yyyy hh:mm. Missing month, date or year fields will be taken relative to today's date, depending on whether the date is expected to belong to the past or the future - see the description of the Direction in time property. A format pattern has the following properties:
- Pattern
-
A pattern that specifies the format of the date to be extracted. See the Syntax of the Relative Date Pattern section later in this topic.
- Locale
-
Specifies the locale that is used in the input. This is for instance used if the input contains the names of months or weekdays, as in 'Monday, 25 May 2009'.
- Default Date
-
This option can be used to specify a date other than the current date to resolve incomplete dates. By default the option is set to Current Date.
- Advanced
-
This tab contains options for specifying a future or a past date. The date that the input should be understood relative to. By default, this is the expression now(), which yields the current date and time.
- Direction in time
-
Specify whether the date to be extracted is a past or future date. This allows the data converter to fill out the missing information if the month and/or year is missing from the format pattern, or when extracting from a relative date. For instance, if extracting from '3 hours ago', the direction in time should be set to 'Past date' in order for the 3 hours to be subtracted from the date specified in 'Relative to', while the direction in time should be set to 'Future date' if you are extracting from input like 'in 5 days'.
- Default Time Zone
-
The default time zone of the date in the input text. If no time zone is selected, no default time zone is used. If a time zone is selected, this time zone is used when no time zone is found in the input text.
- Result Time Zone
-
The time zone to which the date should be converted. If no time zone is selected, no conversion will be done. If a time zone is selected, the date found in the input text will be converted from its time zone (or the default time zone; see above) to this time zone. If the date in the input text has no time zone and no default time zone is selected, no conversion is done.
- Constants
-
Specify language-dependent constants for extracting relative dates where some numbers may be written out rather than specified with numbers. For instance, to be able to extract a date from the input 'Updated an hour ago', a relative date format with the pattern 'HOURS hour[s] ago' must be specified and it is important to make sure that the constant 'an = 1' is defined.
- Description
-
Type in a description to be shown in the list of data converters. If there is no type in a description, one will be generated.
Syntax of the Format Pattern
The following patterns can be combined to create the pattern in the Pattern property:
Pattern |
Description |
---|---|
yy |
Exactly two digit year |
yyy |
Any year |
yyyy |
Exactly four digit year |
YYYY1 |
Exactly four digit week year |
G |
Era marker (AD or BC) |
MM |
One or two digit month, abbreviations or full names of months |
dd |
One or two digit date |
EEE |
Short weekday name (for example, Mon instead of Monday). |
EEEE |
Full weekday name (that is Monday, Tuesday, etc). |
hh or HH |
One or two digit hour |
mm |
One or two digit minute |
ss |
One or two digit second |
a |
AM or PM marker |
Z |
Time Zone identifier (e.g. "PST", "Central European Time" or "GMT+02:00") |
* |
Skip any number of characters |
Space |
Skip one or more white spaces |
Any other character |
Skip that exact character |
If the weekday patterns ('EEE' and 'EEEE') are used and the date pattern ('dd') is not used, then the month and year patterns ('MM' and 'yy'/'yyy'/'yyyy') cannot be used. In this case, the date found is the next day with a name matching the pattern. For example, if the pattern is 'EEEE' and the input is the following text:
Wednesday
the date found is the next Wednesday.
If the weekday patterns are used together with the date pattern (and possibly the month and year patterns), the weekday is discarded. For example, if the pattern is 'EEE, dd/MM/yyy' and the input is the following text:
Mon, 16/03/2003
the date found is '2003-03-16 00:00:00.0' (ignoring whether this is a Monday or not).
Note: The 'EEE' pattern matches the short names of the weekdays (e.g. Mon, Tue etc.). If the pattern should match the entire weekday name, use the 'EEEE' pattern. For example, if the input is the following text:
Thus, let us meet on Wednesday
As the pattern 'EEEE' should be used, as the pattern 'EEE' would match 'Thu' causing the Date Extractor to find next Thursday.
Syntax of Relative Date Pattern
The following date fields can be used in the pattern in the Pattern property of a relative date:
Date Field |
Description |
---|---|
SECONDS |
Seconds |
MINUTES |
Minutes |
HOURS |
Hours |
DAYS |
Days |
MONTHS |
Months |
YEARS |
Years |
Note that time markers like "ago" are not automatically recognized by the step, therefore to extract a relative date in the past, select Past date in the Direction in time list on the Advanced tab. The robot then subtracts the extracted number from the current time.
To extract the date in the future, select Future date in the Direction in time list on the Advanced tab. The robot then adds the extracted number to the current time.
For example, if you want to get the exact time of the "123 seconds ago" string, specify the following:
-
On the Basic tab, select SECONDS sec[s] ago in the Pattern field and now() in Relative To.
-
On the Advanced tab, select Past date in the Direction in time list.
The step then subtracts 123 seconds from the current time.