formatDate(date,string)
Formats a date according to a simple date format and returns the result as a string.
Parameters
- date
-
Java or JavaScript date object
- string
-
'LONG','FULL','MEDIUM','SHORT', or a date pattern string, using the symbols below:Symbol Description Example G
Era
AD
y, yyyy
Year
18, 2018
Q, QQQ
Quarter in year
2, 2nd
M, MM, MMM, MMMM
Month in year
2, 02, Feb, February
w
Week number in year
34
W
Week number in month
3
D
Day number in year
200
d, dd
Day number in month
5, 05
u, uu
Day number in week (Monday = 1)
4, 04
F
Day of week in month
2 (i.e., second Tuesday in month)
E, EEEE
Day of week
Wed, Wednesday
a
AM/PM
PM
H
Hour in day (24-hour; midnight is 0)
23, if time is 11:01PM
0, if time is 12:01AM
1, if time is 1:01AMk
Hour in day (24-hour; midnight is 24)
23, if time is 11:01PM
24, if time is 12:01AM
1, if time is 1:01AMh
Hour in day (12-hour; midnight is 12)
11, if time is 11:01PM
12, if time is 12:01AM
1, if time is 1:01AMK
Hour in day (12-hour; midnight is 0)
11, if time is 11:01PM
0, if time is 12:01AM
1, if time is 1:01AMm, mm
Minute in hour
3, 03
s, ss
Second in minute
9, 09
S, SSS
Millisecond
27, 027
z, zzzz
Time zone
EST, Eastern Standard Time
Z
RFC 822 time zone
-0500
X, XX, XXX
ISO 8601 time zone
-05, -0500, -05:00
Examples
var dateToday = formatDate(new Date(), "hh 'o''clock' a, zzzz");
Some format string pattern examples are shown below:
| Date and time pattern | Result |
|---|---|
|
2006.08.07 AD at 02:19:35 PDT |
|
Mon, Aug 7, ‘06 |
|
12:08 PM |
|
12 o’clock PM, Pacific Daylight Time |
The predefined options ('LONG','FULL','MEDIUM','SHORT') are locale-adapting formats, which means they will display in a manner determined by the user’s locale, for example, “Wednesday, May 22, 2025” in an English locale and “2025年5月22日” in a Chinese locale.
| Predefined string | Result |
|---|---|
|
Thursday, June 5, 2025 |
|
June 5, 2025 |
|
Jun 5, 2025 |
|
6/5/25 |
To reference data when scripting a Data Worksheet Expression Column or Dashboard Calculated Field, use the field syntax. Example:
formatDate(field['Date'], "hh 'o''clock' a, zzzz");
To reference data in Dashboard global script, component script, or property script, use keywords such as value, selectedObjects, data, table, or parameter. Example:
formatDate(parameter.Date, "hh 'o''clock' a, zzzz");
How to access data in Data Worksheet Expression Columns…To create an expression column in a Data Worksheet, press the ‘Create Expression’ button . (See Create a New Data Field for more details.)
Insert fields (and parameters) into the script by clicking the items in the tree. Example syntax:
To reference the data contained in other cells of the data block, see the topics below: Example 1. Cell Referencing
This example illustrates how you can reference the cells of another data block from within an Expression Column. You will use the tables in the folder of the ‘Orders’ data source to create a data block that has columns for product ID, product name, category ID, and category name.
Let’s say that you want to add a column to the ‘PRODUCTS1’ data block that will contain the category name corresponding to each entry in the ‘CAT_ID’ column. The best way to do this is to join the data blocks together (see Join Data), but to practice using cell references, in this case you will create this new column as an expression column. Follow the steps below:
How to access data in Dashboard Calculated Fields…To create a calculated field in a dashboard, right-click on the data block, data model, or query to which you want to add the calculated field, and select ‘New Calculated Field’. (See Create a New Data Field for more details.)
Insert fields (and parameters and component properties) into the script by clicking the items in the tree. Example syntax:
How to access data in Dashboard Property Expressions…To set a Dashboard property value using an expression, press the ‘Value Type’ button and select the ‘Expression’ option to open the Formula Editor. (See Dynamically Set Properties for more details.)
To insert a reference a component’s data, use the value, selectedObjects, data, or table property of the component. Example syntax:
See Dashboard Object Reference for information about accessing dashboard settings and data in script.
How to access data in Dashboard Scripts…To add script to a Dashboard component, right-click the desired component, and select ‘Properties’ from the context menu to open the ‘Properties’ panel. Note: You can also access menu options from the ‘More’ button () in the mini-toolbar. Select the Script tab to open the Script Editor, and select either Script or onClick. See Add Component Script for more information about these options.
To add global script to a Dashboard, press ‘Options’ button in the toolbar to open the ‘Dashboard Options’ panel. Select the Script tab to open the Script Editor, and select either onInit or onRefresh. See Add Dashboard Script for more information about these options.
To insert a reference a component’s data, use the value, selectedObjects, data, or table property of the component. Example syntax:
See Dashboard Object Reference for information about accessing dashboard settings and data in script. |













