Share

Change Datetime Field Values

Description: Add or subtract the specified amount of time from the given date value.
Available Filters: Event Filters:
- Event Type
- Event Field

Field Filters:
- Field Name
- Field Value
Settings: Datetime Field: The date or time factor that you want to change in the existing value. For example, Month.
Offset Value: The count to be added to or subtracted from the selected datetime field. Use a negative value to subtract the time. For example, enter 1 to move the month forward by 1, and -1 to move the month back by 1.

Read Datetime Field Values.
Transformation Considerations: - The date must be a valid date object. Alternatively, you can use another Transformation block to get the date in a valid format, for example, use the Parse Date from String block if the date exists as a string value.
- A positive datetime value is added whereas a negative value is subtracted from the existing field value.

Sample Transformation

Scenario: Move the time in the joining_date field ahead by 5 hours in all Events of the agents Event Type.

Option 1: If the date is a valid date object

Filters:

  • Event Type = agents
  • Events = All Events (default)
  • Fields = All fields with name = joining_date

Settings:

  • Datetime Unit = Hour of Day
  • Amount = 5

Change datetime settings

Result: When you test the Transformation, the joining date, 1041333630000 (Tuesday, 31 December 2002 11:20:30), is moved ahead by 5 hours to 1041351630000 (Tuesday, 31 December 2002 16:20:30).

Change datetime

Option 2: If the date is not a valid date object

In this case, the date is first converted to a suitable format, and post-that, it is modified:

  1. Use the Parse Date from String Transformation block to change the joining_date to a timestamp value:

    Filters:

    • Event Type= agents
    • Fields = All fields with name = joining_date

    Settings:

    • String format: The format in which the date exists. yyyy-MM-dd hh:mm:ss

    parse date from string settings

    Result: When you test the Transformation, the value 2001-02-20 11:20:30 in the joining_date field is changed to the timestamp, 982668030000:

    parse date from string Settings

  2. Use the Change Datetime Value Transformation block to move the time value ahead by 5 hours:

    Filters:

    • Event Type= agents
    • Fields = All fields with name = joining_date

    Settings:

    • Datetime Unit = Hour of day
    • Amount = 5

    Change datetime settings

    Result: When both Transformations are tested together, they increase the time value in the joining_date field by 5 hours from 2001-02-20 11:20:30 to 2001-02-20 16:20:30. The final value, 982686030000 is of timestamp data type.

    Change datetime from string

Last updated on May 30, 2023

Tell us what went wrong

Skip to the section