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.
toBool(<parameter>)
decimal
-
boolean
-
string
-
integer
boolean
toBool("true")
→ true
-
toBool(1)
→ true
-
toBool("this is not a boolean")
→ false
toDateOnly(<parameter>)
string (XDM format "YYYY-MM-DD")
-
dateTime
-
dateTimeOnly
-
integer (epoch milliseconds)
dateOnly
toDateOnly("2023-08-18")
→ DateOnly 2023-08-18
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(<parameter>)
dateTime (ISO-8601 or "YYYY-MM-DD")
-
dateTime
dateTimeOnly
toDateTimeOnly("2023-08-18")
→ 2023-08-18T00:00:00.000
toDecimal(<parameter>)
string
-
dateTime
-
boolean
-
integer
decimal
toDecimal("4.0")
→ 4.0
toDuration(<parameter>)
string (ISO-8601 format)
-
integer (milliseconds)
duration
toDuration("PT10H")
→ 10 hours durationtoInteger(<parameter>)
string
-
dateTime
-
decimal
-
boolean
integer
toInteger("4")
→ 4
toString(<parameter>)
dateTime
-
dateTimeOnly
-
duration
-
integer
-
decimal
-
boolean
string
toString(4)
→ "4"
-Ìý
toString(toDuration(1520))
→ "PT1.52S"