Check if the Field is a Date

Last updated on Jun 30, 2023
Definition: isDate(fieldname: str) → bool
Description: Checks if a specific field is of date data type. The return value can be further used to transform the data. For example, deleting data created before Jan 01, 2020.
Parameters: fieldname: The name of the field whose value is to be checked.
Returns: True, if the specified field’s value is of type, date.
False, for null and other data type values, including datetime.

The following script checks if the specified property is a date:

from io.hevo.api import Event

def transform(event):
    <existing_properties> = event.getProperties()

    <boolean_value_type> = event.isDate('<property_name>')

    return event

Sample Transformation

The following script checks if the Created On property is a date. The isDate property displays the return value of the method:

from io.hevo.api import Event

def transform(event):
    properties = event.getProperties()

    # Set a property to the return value of the method
    properties['isDate'] = event.isDate('Created On')

    return event

Sample Output

The Transformation sets the isDate property to true, as Created On is a date.

Is a Date



Revision History

Refer to the following table for the list of key updates made to this page:

Date Release Description of Change
Feb-14-2023 NA New document.

Tell us what went wrong