Runtime verified Test scripts included

Returns one part of a date or timestamp as a number, for example the year.

Syntax

{{datePart date part}}

Returns integer.

Parameters

Name Type Required Description
date any Yes The date or timestamp to read from.
part string Yes Component to return: Y, M, D, H, or MI.

Example

Tested in a Marketing Cloud Next email on 2026-11-22:

  • {{datePart "2023年8月5日" "Y"}} renders 2023, as documented.
  • {{datePart "2025-03-15 14:30:00" "MI"}} renders 30, as documented.
Show Next test script
<!-- Marketing Cloud Next test script for the datePart helper. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[2023] got=[{{datePart "2023年8月5日" "Y"}}]</p>
<p>c2 expect=[30] got=[{{datePart "2025-03-15 14:30:00" "MI"}}]</p>

Marketing Cloud Next

Works as documented

Every tested call rendered the documented result. Tested 2026-11-22 by rendering in a Marketing Cloud Next email.

See also