Handlebars Helper Function: datePart

Extracts a specified part of a date or timestamp, such as the day, month, or year.

This helper is available in the Winter ’27 release of Marketing Cloud Next.

ParameterTypeDescription
dateString or ObjectRequired. The date or timestamp from which to extract a date part.
datePartStringRequired. The date part to extract. Possible values: Y (year), M (month), D (day), H (hour), or MI (minute).

Specify date in these formats:

  • US formats: MM/dd/yyyy, M/d/yyyy, MM/dd/yyyy HH:mm:ss, M/d/yyyy h:mm a, or M/d/yyyy h:mm:ss a

  • ISO formats: yyyy-MM-dd, yyyy-MM-dd HH:mm:ss, yyyy-MM-dd'T'HH:mm:ss, or yyyy-MM-dd'T'HH:mm:ss.SSSZ

  • 12-hour time: M/d/yyyy h:mm a, yyyy-MM-dd h:mm a, or yyyy-MM-dd h:mm:ss a

  • Time-only: h:mm a or h:mm:ss a

    If you specify only a time, the helper function uses the current date.

  • Long-form English: d MMMM yyyy, MMMM d, yyyy, or EEEE, MMMM d, yyyy

  • Chinese or Japanese notation: yyyy年M月d日

  • Korean notation: yyyy년 M월 d일 or yyyy년M월d일

The function returns the requested date part as an integer. For example, {{datePart "2023年8月5日" "Y"}} returns 2023.