Date and time functions are used to perform date and time operations on values within Journey Optimizer.
The age
function is used to retrieve the age from a given date.
Syntax
{%= age(datetime) %}
The currentTimeInMillis
function is used to retrieve current time in epoch milliseconds.
Syntax
{%= currentTimeInMillis() %}
The dateDiff
function is used to retrieve the difference between two dates in number of days.
Syntax
{%= dateDiff(datetime,datetime) %}
The dayOfWeek
function is used to retrieve the day of week.
Syntax
{%= dayOfWeek(datetime) %}
The dayOfYear
function is used to retrieve the day of year.
Syntax
{%= dayOfYear(datetime) %}
The formatDate
function is used to format a date time value. The format should be a valid Java DateTimeFormat pattern.
Syntax
{%= formatDate(datetime, format) %}
Where the first string is the date attribute and the second value is how you would like the date to be converted and displayed.
If a date pattern is invalid the date will fallback to ISO standard format.
You can use Java date formatting functions as summarized in Oracle documentation
Example
The following operation will return the date in the following format: MM/DD/YY.
{%= formatDate(profile.timeSeriesEvents._mobile.hotelBookingDetails.bookingDate, "MM/dd/YY") %}
The formatDate
function is used to format a date time value into its corresponding language sensitive representation, i.e in a desired locale. The format should be a valid Java DateTimeFormat pattern.
Syntax
{%= formatDate(datetime, format, locale) %}
Where the first string is the date attribute, second value is how you would like the date to be converted and displayed and the third value represents the locale in string format.
If a date pattern is invalid the date will fallback to ISO standard format.
You can use Java date formatting functions as summarized in Oracle documentation.
You can use formatting and valid locales as summarized in Oracle documentation and Supported locales.
Example
The following operation will return the date in the following format: MM/DD/YY and locale FRANCE.
{%= formatDate(profile.timeSeriesEvents._mobile.hotelBookingDetails.bookingDate, "MM/DD/YY", "fr_FR") %}
The setDays
function is used to set the day of the month for the given date-time.
Syntax
{%= setDays(datetime, day) %}
The setHours
function is used to set the hour of the date-time.
Syntax
{%= setHours(datetime, hour) %}
The toUTC
function is used to convert a datetime to UTC.
Syntax
{%= toUTC(datetime) %}
The weekOfYear
function is used to retrieve the week of the year.
Syntax
{%= weekOfYear(datetime) %}