ecm:toDate
    • 1 Minute to read
    • Dark
      Light

    ecm:toDate

    • Dark
      Light

    Article summary

    The function ecm:toDate converts a target string or value into a date data type. The value returned is a date data type.

    This function is often used to convert values to dates for use with functions that require date data types in parameters.

    Example

    A selection determines whether recipients who are near retirement age receive a message. The segment criteria compare the date of birth stored as an attribute value to a specific date (1 January 1950). In order to compare the two dates using the function ecm:less, both values must be date data types. The function ecm:toDate converts the string '1950-01-01' into a date data type so it can be compared with the date stored in the recipient attribute ​user['DateofBirth']​. The combined functions are constructed as follows:

    ${ecm:less(user['DateOfBirth'], ecm:toDate('1950-01-01', ecm:timeZone('Europe/Berlin')))}

    Structure​

    ecm:toDate(string, timezone)

    Parameters​

    Parameter

    Description

    string

    Specifies the target value to be converted into date format. Formats that are correctly converted into dates include:

    • yyyy-MM-dd

    • dd.MM.yyyy

    • yyyy-MM-dd hh:mm:ss

    • dd.MM.yyyy hh:mm:ss

    timezone

    The time zone used as reference for the date. If not specified, the system default time zone is used.


    Was this article helpful?

    What's Next