convertdates

Convert dates into python datetime.

Introduction

Use the convertdates enrichment instruction to convert dates into Python datetime. By default, this instruction uses the Python module and class datetime.date.

Creating the enrichment

For more information on creating an enrichment, see Using custom scripts.

Configuring the enrichment

To configure the enrichment, fill in the following fields. Required fields are marked with an asterisk (*).

Fields

Enter the names of the columns that contain the dates to convert.

Auto

Select this field to automatically detect the format of the dates.

Format

If the Auto field is unselected, enter the format of the dates to be converted. For example, the format of the date 2020-03-31 is %Y-%m-%d.

Datetime

Select this field to convert the dates to date and time (this uses Python module and class datetime.datetime). To convert the dates to a date only, leave this field unselected (this uses Python module and class datetime.date instead).

Strict

If selected, the value None is returned if the date conversion fails.

Example

Enrichment configuration

Fields

Campaign Start Date

Campaign End Date

Format

%Y-%m-%d

Datetime

Leave this field unselected.

Data tables before enrichment

Campaign

Campaign Start Date

Campaign End Date

Brand

2022-01-10

2022-01-15

Outreach

2022-01-10

2022-01-31

Organic Growth

2021-12-13

2022-02-02

Data after before enrichment

Campaign

Campaign Start Date

Campaign End Date

Brand

Jan. 10, 2022

Jan. 15, 2022

Outreach

Jan. 10, 2022

Jan. 31, 2022

Organic Growth

Dec. 13, 2021

Feb. 2, 2022