On This Page

Formatting Functions

Functions for formatting values for display. These functions are primarily available in dashboard expressions.

info

formatDuration, formatPercentage, formatNumber and formatCurrency are available in frontend expressions (dashboards, displays) only. formatDate is available in both frontend expressions and server-side calculated attributes.

Common Patterns

  • Display Dates:

    formatDate(StartTime, "yyyy-MM-dd")         // 2024-03-15
    formatDate(StartTime, "MMM d, yyyy")        // Mar 15, 2024
    formatDate(StartTime, "HH:mm:ss")           // 14:30:45
    formatDate(StartTime, "EEEE, MMMM d")       // Friday, March 15
  • Format Duration:

    formatDuration(3600000)                     // "1 h"
    formatDuration(90000, "s")                  // "90 s"
    formatDuration(86400000, "d")               // "1 d"
  • Display Percentages:

    formatPercentage(0.75)                      // "75%"
    formatPercentage(0.333)                     // "33.3%"

Date Format Patterns

Uses a subset of the date-fns format patterns. Supported tokens for formatDate:

  • Year:

    yyyy   4-digit year      2024
  • Month:

    MM     Month (2 digits)  03
    MMM    Month (short)     Mar
    MMMM   Month (full)      March
  • Day:

    dd     Day (2 digits)    15
    d      Day               15
    EEEE   Day name (full)   Friday
    EEE    Day name (short)  Fri
  • Time:

    HH     Hour (24h)        14
    mm     Minutes           30
    ss     Seconds           45

Duration Units

Available in frontend expressions only. Uses short unit labels:

ms     Milliseconds
s      Seconds
m      Minutes
h      Hours
d      Days
mo     Months
y      Years

formatDate

(timestamp, format)

Formats a timestamp using a date format pattern.

Parameters
timestamp number Timestamp to format
format string Format pattern, for example, 'yyyy-MM-dd' or 'HH:mm'
Returns string
Examples
formatDate(StartTime, "yyyy-MM-dd") → 2024-03-18
formatDate(StartTime, "HH:mm") → 14:30
Notes

Supported tokens are derived consistently for frontend and Athena: yyyy, MM, dd, HH, mm, ss, with M, d, H, m, s and MMM, MMMM, EEE, EEEE also supported for formatting. Formatting uses UTC semantics.

formatDuration

(duration, unit?)

Formats a duration in milliseconds as a readable string.

Parameters
duration number Duration in milliseconds
unit (optional) string Display unit: 'ms', 's', 'm', 'h', 'd', 'mo', 'y'
Returns string
Examples
formatDuration(3600000) → 1 h
formatDuration(90000, "s") → 90 s
Notes

Available in frontend expressions only. Uses short unit labels (s, m, h, d, mo, y).

formatPercentage

(value)

Formats a decimal value as a percentage.

Parameters
value number Decimal value (0.5 = 50%)
Returns string
Examples
formatPercentage(0.75) → 75%
formatPercentage(1.5) → 150%
Notes

Available in frontend expressions only.

formatNumber

(value, decimals?)

Formats a number with optional decimal places. Frontend only.

Parameters
value number Number to format
decimals (optional) number Number of decimal places
Returns string
Examples
formatNumber(1234.5, 2) → 1,234.50
Notes

Available in frontend expressions only.

formatCurrency

(value, currency, decimals?)

Formats a number as currency. Frontend only.

Parameters
value number Number to format
currency string ISO 4217 currency code, for example, EUR or USD
decimals (optional) number Number of decimal places
Returns string
Examples
formatCurrency(99.9, "EUR") → €99.90
Notes

Available in frontend expressions only.

Design better processes. Build a connected architecture. Stay in control.

Get instant access with no credit card and no waiting. Turn the way your organization works into clear, connected process designs.

Build your process architecture, define ownership and controls, and align roles and responsibilities across every level.

Start your free trial and create one reliable foundation for governing, managing, and continuously improving your processes.