One of the most frustrating situations is realizing that the data type of a customer attribute isn't suitable for the operation you need to perform. Storing values as string can be problematic when:
- You want to use the attribute in mathematical operations (expressions).
- You expect it to behave correctly in date filters in Analytics or campaigns.
This guide shows a workaround using a scenario "Set attribute" node. Instead of changing the original attribute in place, you will:
- Read the original, misformatted string attribute.
- Convert it to a UNIX timestamp via Jinja.
- Store the result in a new customer attribute.
Workaround via Scenario "Set attribute" node
We'll not change the existing attribute directly. Instead, we'll create a new customer attribute that holds the converted UNIX timestamp.
Step by step
Create a scenario
- Use your preferred trigger (for example, NOW).
- Add a Condition node to target the customer profiles you want to convert.
- After the condition, add a Set attribute node.
Create the new attribute
- In the Set attribute node, type the name of the new customer attribute.
- A typical pattern is to reuse the original name with a suffix, for example:
date_of_birth_converted
- A typical pattern is to reuse the original name with a suffix, for example:
Click the + icon to create it.
- In the Set attribute node, type the name of the new customer attribute.
Configure the value with Jinja
- Set Data type = Number in the Set attribute node.
In the "Value" field, use Jinja to convert the original string attribute to a UNIX timestamp. For example:
{{ customer.date_of_birth | to_timestamp }}- Next:
- References the original attribute
customer.date_of_birth. Uses the
to_timestampfilter to convert it to a UNIX timestamp (numeric).
- References the original attribute
Run the scenario and verify
- Start the scenario and let it process the targeted customers.
- Open one of the affected customer profiles and confirm that the new attribute (for example
date_of_birth_converted) has been populated with a numeric UNIX value.
Finalize in Data Manager
- Go to Data management → Customer properties.
- Locate the new converted attribute.
- Set its type to Date time so it behaves correctly in:
- date filters (Analytics, campaigns)
expressions that expect a date/time value