Formatting

◷ Reading Time: 2 minutes

format

Binds values of execution context to a parameterized string value. Parameters in the string should be surrounded by { and }.

input |format (ncv)
Example: 
name:= "John"
'hello {name}'|format () 
Result: hello John
        
The name is a parameter with a predefined value, John. Therefore, it's used in the format.
Example: '{name} is cool!'|format ({name:'FlexRule'}) 
Result: FlexRule is cool!

formatDate

Format a date to a string value with a specific display format. It will return the formatted value as a string

input |formatDate (format)
  • input (Date): Date that needs to be formatted
  • format: Below is the list of formatters that can be used:
    • year: y yy yyy yyyy
    • month: M MM MMM MMMM
    • day: d dd ddd dddd
    • hour: h hh H HH
    • minute: m mm
    • second: s ss
    • AM/PM: t tt
Example: today()|formatDate (dd/MM/yyyy)
Result: 04/12/2020
Example: '4/12/2020 12:00:00 AM'|asDate()|formatDate (dd/MMMM)
Result: 04/December
Example: '13:45'|asDate()|formatDate (hh:mm:ss tt)
Result: 01:45:00 PM

formatNumber

Format a numeric value.

input |formatNumber (format)
  • input (Number): Number that needs to be formatted
  • format: Format of the numbers
Example: 12323d|formatNumber (#,##.00)  
Result: 12,323.00
Updated on January 12, 2021

Was this article helpful?

Related Articles