51ºÚÁϲ»´òìÈ

Journey conversion functions

In Journey Optimizer, conversion functions enable the seamless transformation of data types to suit different data processing needs. These functions are particularly useful for data engineers and architects, allowing them to manipulate and convert data types such as strings, numbers, and dates into the desired format for efficient data handling and integration.

Example usage

Imagine you are setting up a journey to send a welcome email to users who sign up. You have a field in your database that stores the signup date as a string, and you need to convert it to a DateTime to compare it with the current date to trigger the email:

var signupDateString = "2023-08-18";
var signupDate = toDateTime(signupDateString);
var currentDate = toDateTime("now");

if (signupDate < currentDate) {
    sendEmail("Welcome to our service!");
}

In this example, toDateTime is used to convert the string signupDateString into a DateTime object, which can then be compared to the current date to decide whether to send the email. This demonstrates the function’s utility in data processing and decision-making within 51ºÚÁϲ»´òìÈ Journey Optimizer.

Function
Description
Syntax
Parameters
Returns
Examples
toBool
Converts a value to a boolean.
toBool(<parameter>)
- decimal
- boolean
- string
- integer
boolean
- toBool("true") → true
- toBool(1) → true
- toBool("this is not a boolean") → false
toDateOnly
Converts a value to a date-only format.
toDateOnly(<parameter>)
- string (XDM format "YYYY-MM-DD")
- dateTime
- dateTimeOnly
- integer (epoch milliseconds)
dateOnly
- toDateOnly("2023-08-18") → DateOnly 2023-08-18
toDateTime
Converts values to a date-time format.
toDateTime(<parameter>)
- dateTime (ISO-8601 format)
- Time zone ID
-ÌýdateTimeOnly
- integer (epoch milliseconds)
dateTime
- toDateTime("2023-08-18T23:17:59.123Z") → 2023-08-18T23:17:59.123Z
toDateTimeOnly
Converts a value to a date-time only format.
toDateTimeOnly(<parameter>)
- dateTime (ISO-8601 or "YYYY-MM-DD")
- dateTime
dateTimeOnly
- toDateTimeOnly("2023-08-18") → 2023-08-18T00:00:00.000
toDecimal
Converts a value to a decimal format.
toDecimal(<parameter>)
- string
- dateTime
- boolean
- integer
decimal
- toDecimal("4.0") → 4.0
toDuration
Converts a value to a duration.
toDuration(<parameter>)
- string (ISO-8601 format)
- integer (milliseconds)
duration
- toDuration("PT10H") → 10 hours duration
toInteger
Converts a value to an integer format.
toInteger(<parameter>)
- string
- dateTime
- decimal
- boolean
integer
- toInteger("4") → 4
toString
Converts a value to a string format.
toString(<parameter>)
- dateTime
- dateTimeOnly
- duration
- integer
- decimal
- boolean
string
- toString(4) → "4"
-ÌýtoString(toDuration(1520)) → "PT1.52S"
recommendation-more-help
91a6d90a-6d61-4a62-bbed-ae105e36a860