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:

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 Format Pattern section below.
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'.
A relative date allows extraction of a date from input such as '3 hours ago' where the time is interpreted relative to another date. It 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 below.
Relative to:
The date that the input should be understood relative to. By default, this is the expression now(), which yields the current date and time. Other typical values include using a date stored in a variable.
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 Meaning
yy Exactly two digit year
yyy Any year
yyyy Exactly four digit year
MM One or two digit month, abbreviations or full names of months
dd One or two digit date
EEE Short weekday name (e.g. Mon instead of Monday).
EEEE Full weekday name (e.g. Monday).
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"

the pattern 'EEEE' should be used, since the pattern 'EEE' would match 'Thu' causing the Date Extractor to find next Thursday.

Examples of Format Patterns

Here are some examples of format patterns and matching dates:

Format Pattern Matching Dates
dd/MM-yyy 7/6-78
24/12-2001
1/jan-2001
dd. MM yyy 4. jan 1993
4. january 93

Syntax of the Relative Date Pattern

The following date fields can be used in the pattern in the Pattern property of a relative date:

Date Field Meaning
SECONDS Seconds
MINUTES Minutes
HOURS Hours
DAYS Days
MONTHS Months
YEARS Years

To specify optional parts of the pattern, include these in square brackets [ ].

Examples of Relative Date Patterns

Here are some examples of relative date patterns:

Format Pattern Matching Dates
HOURS hour[s] ago 4 hours ago
an hour ago (if constant an = 1 is defined)
HOURS hour[s] and MINUTES minute[s] ago 3 hours and 5 minutes ago
[HOURS hour[s] ]MINUTES minute[s] ago 4 hours 1 minute ago
15 minutes ago

Videos

Following are two videos on date extraction techniques. The first video is a simple tutorial example which builds on the News Magazine robot from the beginner tutorials. The second video is a more complex example.