Extracting parts of a date from attribute values

You can extract date patterns from a Date Time attribute and use that information to create a new attribute or overwrite an existing attribute.

For example, this may be useful if an attribute has a timestamp and you want to extract the day of the week value and create a new attribute called Day.

To extract parts of a date from attribute values:

  1. In the Catalog, select a project.
  2. Select Transform.
  3. Locate an attribute of type Date Time that has date information that you want to extract.
  4. From the transform menu, select Basic > Extract date part.
  5. Specify a date pattern for the attribute values in one of the following ways:
    • In Select a data part..., select a date format from the list of pre-defined format patterns.
    • Alternatively, you can enable Create a custom data part and specify a custom date pattern. Specify only the date pattern not a label for the pattern. For example, if you want to create a custom pattern for Year-Month-Day, you specify only yyyy-MM-dd.
  6. Select an output time zone for the date pattern. This setting normalizes the attribute values to the time zone you specify.
  7. Select an output locale from the available list. This setting converts character (non-numeric) date information to the locale you specify.
    For example, if you extract a day pattern, such as dd, and set the output locale to Japanese, the new attribute values contain the day names in Japanese.
  8. Indicate whether you want the Extract Date Part transformation to apply to the attribute you selected previously, or indicate whether you want to create a new attribute using the extracted date information.
  9. If you selected Create New Attribute, then specify an attribute name.
  10. Either click Preview to see the previewed results of running the transformation, or click Add to Script to save the transformation step to the script.

Example 19-2 Example

Suppose your source data has attributes named dropoff_datetime and you want to extract the day value and use it to create dropoff_day. You can create the attributes by setting the Extract Date Part as follows:
Shows an example of configuring the Extract Date Part editor to create a new day attribute.

After you click Preview, you see that Studio creates the following new dropoff_day attribute highlighted in yellow:
Shows an example of the resulting new new day attribute in the table view.

If you are done making changes to the project data set, you can commit the changes. See Running the transformation script against a project data set.