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.
Format
{%= age(date) %}
The currentTimeInMillis
function is used to retrieve current time in epoch milliseconds.
Format
{%= currentTimeInMillis() %}
The dateDiff
function is used to retrieve the difference between two dates in number of days.
Format
{%= dateDiff(datetime,datetime) %}
The dayOfWeek
function is used to retrieve the day of week.
Format
{%= dayOfWeek(datetime) %}
The dayOfYear
function is used to retrieve the day of year.
Format
{%= dayOfYear(datetime) %}
The formatDate
function is used to format a date time value. The format should be a valid Java DateTimeFormat pattern.
Format
{%= formatDate(date, 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 setDays
function is used to set the day of the month for the given date-time.
Format
{%= setDays(date, day) %}
The setHours
function is used to set the hour of the date-time.
Format
{%= setHours(date, hour) %}
The toUTC
function is used to convert a datetime to UTC.
Format
{%= toUTC(datetime) %}
The weekOfYear
function is used to retrieve the week of the year.
Format
{%= weekOfYear(datetime) %}