Date Time Functions date-time

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

Age age

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

Syntax

 {%= age(datetime) %}

Current time in milliseconds current-time

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

Syntax

{%= currentTimeInMillis() %}

Date difference date-diff

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

Syntax

{%= dateDiff(datetime,datetime) %}

Day of week day-week

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

Syntax

{%= dayOfWeek(datetime) %}

Day of year day-year

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

Syntax

{%= dayOfYear(datetime) %}

Format date format-date

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.

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

Format date with locale support format-date-locale

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.

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

Set days set-days

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

Syntax

{%= setDays(datetime, day) %}

Set hours set-hours

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

Syntax

{%= setHours(datetime, hour) %}

To UTC to-utc

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

Syntax

{%= toUTC(datetime) %}

Week of year UTC week-of-year

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

Syntax

{%= weekOfYear(datetime) %}
recommendation-more-help
b22c9c5d-9208-48f4-b874-1cefb8df4d76