formatDate()

The formatDate() function is used to format dates.

Syntax

formatDate(date, mask)

Argument Description
date

(required)

An expression that results in a date value (i.e., a hard-coded date, a reference to a date attribute, or a function that returns a date value).
mask

(required)

The format for the date display defined using pattern letters.

The table below lists commonly used pattern letters (please note these are case sensitive):

Letter Date Component Format Examples
D Day of year Number 189
d Day of month Number 10
E Day of week Text Tue; Tuesday; T
M Month of year Number/text 7; 07; Jul; July
Q Quarter of year Number/text 3; 03; Q3; 3rd quarter
w Week of year Number 27
W Week of month Number 3
y Year Year 2004; 04

The count of pattern letters determines the format.

Text: The text style is determined based on the number of pattern letters used. Less than 4 pattern letters will use a short form. Exactly 4 pattern letters will use a full form. Exactly 5 pattern letters will use a narrow form.  E.g., for 2/28/2021:

  • M = 2
  • MM = 02
  • MMM = Feb
  • MMMM = February
  • MMMMM = F

Number: If the count of letters is one, then the output value uses the minimum number of digits without padding (e.g. 1, or 12). Otherwise, the count of letters is used as the length of the output value, with the value zero-padded as necessary (e.g. 001, or 012). Note: ‘W’ can only be used as a single letter, up to two letters of ‘d’  and ‘w’ can be specified; up to three letters of ‘D’ can be specified. E.g., for 1/08/2021:

  • D = 8
  • DD = 08
  • DDD = 008

Number/Text: If the count of pattern letters is 3 or greater, use the Text rules above. Otherwise use the Number rules above. E.g., for 2/28/2021:

  • Q = 1
  • QQ = 01
  • QQQ = Q1
  • QQQQ = 1st quarter
  • QQQQQ = 1

Year: The count of letters determines the minimum output value length below which padding is used. If the count of letters is two, then a reduced two-digit form is used. E.g., for 2/28/2021:

  • y = 2021
  • yy = 21
  • yyy = 2021
  • yyyy = 02021

A full list of available pattern letters can be found here.

Where Available

  • Available in all places the injected expression icon is visible, as well as within Filter fields on Cards, Tables and List/View sections.

Examples

Where Example(s)
Business rules: Set Value

Attribute expression

formatDate(Close_Date__c, “MMM dd, yyyy”) result: Dec 31, 2023

formatDate(startDate, “EEEE”) result: Thursday

value(formatDate(Close_Date__c, "w"))-value(formatDate(Open_Date__c,"w")) result: 5 (number of weeks between open date and close date)

formatDate(Program_Start_Date__c, Format_Mask__c)

Field Editability expression

Tab Visibility expression

Business rules: Condition

(value(formatDate(Close_Date__c, "w")) - value(formatDate(today(),"w"))) < 2
Business rules: Notification Subject

Business rules: Notification Body

Dynamic Filter

{!value(formatDate(Close_Date__c, "w")) - value(formatDate(Open_Date__c,”w”))}

{!formatDate(Close_Date__c, “yyyy-MM-dd”)}

result: 2020-12-31

Embedded Section URL attribute

Business Rule: URL Call

External View URL on List/View

{!if((formatDate(Close_Date__c, "EE"))="Mon",URL1__c,URL2__c)}
Metric expression value(formatDate(Close_Date__c, "w"))-value(formatDate(Open_Date__c,"w"))

 

Updated on January 29, 2024

Related Articles