Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Overview

The Date Time Extractor is a Transform type Snap that is used to extract components from datetime data and add them to the result field. You can use the Snap to prepare the data before performing aggregation or analysis. For example, to identify the total sales for each month or quarter. 

Info

The Date Time Extractor Snap is an alternative to the Date class in the expression language.

Expected Input and Output

  • Expected input: A document with datetime fields.
  • Expected output: A document with fields that contain datetime components.
  • Expected upstream Snaps: Any Snap that has a document output stream. For example, Mapper, JSON Parser, etc.
  • Expected downstream Snaps: Any Snap that has a document input stream. For example, Aggregate, Profile, etc.

Prerequisite

The input document must contain datetime fields.

Configuring Accounts

Accounts are not used with this Snap.

Configuring Views

Input

This Snap has exactly one document input view.

OutputThis Snap has exactly one document output view.
ErrorThis Snap has at most one document error view.

Troubleshooting

None

Limitations and Known Issues

None

Modes


Snap Settings


LabelRequired. The name for the Snap. You can modify this to be specific, especially if you have more than one of the same Snap in your pipeline.
Policy

Specify your preferences for the date time extraction. Each policy contains an input field, component, and the result field. The Snap extracts the date or time component from the input field value and writes it to the result field.

Field

Required. Select the datetime field in the input document. This is a suggestible field that suggests all the fields in the incoming dataset. 

Info

Ensure the field is in datetime type. To convert text to datetime, use the Type Converter Snap.

Default value: None

Component

Choose the component that the Snap must extract from the input field. The available options are:

  • Date
  • Date String (yyyy-MM-dd)
  • Date Time String (YYYY-MM-dd-HH:mm:ss)

  • Date Time String (YYYY-MM-dd HH:mm:ss.SSS)
  • Year
  • Quarter
  • Month
  • Day
  • Hour
  • Minute
  • Second
  • Millisecond
  • Year and Month (yyyy-MM)
  • Week of Year
  • Day of Year
  • Day of Week
  • Day of Week String (Sunday)
  • Month of Year String (January)
  • Epoch
  • Epoch Millisecond
Info
  • When setting a map path as a path of the date-time fields, the Snap checks all the fields in the map and converts them to the selected date-time pattern.

  • When setting a root path as a path of the date-time field, the Snap checks all fields in the root object and converts them to the selected date-time pattern. However, we recommend you use the root path only once, and if a second component is added, then the second component is converted to the specified DateTime format, ignoring the first component.

  • Year
  • Quarter
  • Month
  • Day
  • Hour
  • Minute
  • Second
  • Millisecond
  • Year and Month (yyyy-MM)
  • Week of Year
  • Day of Year
  • Day of Week
  • Day of Week String (Sunday)
  • Month of Year String (January)
  • Epoch
  • Epoch Millisecond

Default value: Date

Result field

Required. Specify the result field to be used in the output map. If the Result field is the same as Field, the values are overwritten. If the Result field does not exist in the original input document, a new field is added. 

Default value: None

Snap Execution


Select one of the following three modes in which the Snap executes:

  • Validate & Execute: Performs limited execution of the Snap, and generates a data preview during Pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during Pipeline runtime.

  • Execute only: Performs full execution of the Snap during Pipeline execution without generating preview data.

  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default ValueExecute only



Example: Validate & Execute



Example

Simple Date Time Extraction

This pipeline demonstrates how we can extract date and time components from an input data using the Date Time Extractor Snap. 

  Download this pipeline.

Expand
titleUnderstanding the pipeline

In this example, the Mapper Snap is used to generate a datetime object. The text 2013-02-01 is parsed into a datetime object using the Date.parse function in the Mapper Snap. The Mapper Snap configuration is as follows:

The datetime object generated by the Mapper Snap is as follows:

The datetime object from the Mapper Snap is passed to the Date Time Extractor Snap. The Date Time Extractor Snap is configured as follows:

The output preview of the Date Time Extractor Snap is as follows:

You can see that all the date time components from the input data are extracted.

Download this pipeline.


Insert excerpt
ML Data Preparation Snap Pack
ML Data Preparation Snap Pack
nopaneltrue