Date Time Functions

Date and time functions are used to perform date and time operations on values within Journey Optimizer.

Age

The age function is used to retrieve the age from a given date.

Format

 {%= age(date) %}

Current time in milliseconds

The currentTimeInMillis function is used to retrieve current time in epoch milliseconds.

Format

{%= currentTimeInMillis() %}

Date difference

The dateDiff function is used to retrieve the difference between two dates in number of days.

Format

{%= dateDiff(datetime,datetime) %}

Day of week

The dayOfWeek function is used to retrieve the day of week.

Format

{%= dayOfWeek(datetime) %}

Day of year

The dayOfYear function is used to retrieve the day of year.

Format

{%= dayOfYear(datetime) %}

Format date

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.

NOTE

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") %}

Set days

The setDays function is used to set the day of the month for the given date-time.

Format

{%= setDays(date, day) %}

Set hours

The setHours function is used to set the hour of the date-time.

Format

{%= setHours(date, hour) %}

To UTC

The toUTC function is used to convert a datetime to UTC.

Format

{%= toUTC(datetime) %}

Week of year UTC

The weekOfYear function is used to retrieve the week of the year.

Format

{%= weekOfYear(datetime) %}

On this page