Data Formatting Codes
In This Topic...
Some format options can be selected from a list, while others can be entered as formatting codes. The following tables provide the common codes that can be used throughout the system.
Text Formatting
When working with content where the Data Type is Text, additional text can be included before and after the data, and will appear in every row.
The {0} code represents the data itself, and should not be removed or altered. Text can be added before and after the code.
For example, if a data column contains first names, the formatting code "First name: {0}" would produce "First name: John".
Number Formatting
These codes can be used to format content where the Data Type is Integer or Decimal.
All examples are from the source value "1234.5678".
Format | Code | Example |
Notes |
Number | {0:N#} | {0:N2} produces 1,234.57 |
Formats the value as a number, including thousands separators. The # variable specifies the number of decimals. If the value has more decimals than permitted, the value will be rounded off. |
Percentage | {0:P#} | {0:P1} produces 123,456.8 % |
Converts the value to a percentage, including thousands separators and the % sign. The # variable specifies the number of decimals. If the value has more decimals than permitted, the value will be rounded off. |
Currency | {0:C#} | {0:C2} produces $1,234.57 |
Formats the value as a currency, including thousands separators and the appropriate currency symbol. The # variable specifies the number of decimals. If the value has more decimals than permitted, the value will be rounded off. |
Date Formatting
These codes can be used to format content where the Data Type is Date.
The following are pre-formatted codes that cannot be combined with other codes.
All examples below are from the source date "2016-06-15T14:55:22.12-04:00".
Format | Code | Example | Notes |
Date (short) | {0:d} | 6/15/2016 | |
Date (long) | {0:D} | Wednesday, June 15, 2016 | |
Time | {0:t} | 2:55 PM | |
Time, with seconds | {0:T} | 2:55:22 PM | |
Date (short) and Time | {0:g} | 6/15/2016 2:55 PM | |
Date (short) and Time, with seconds | {0:G} | 6/15/2016 2:55:22 PM | |
Date (long) and Time | {0:f} | Wednesday, June 15, 2016 2:55 PM | |
Date (long) and Time, with seconds | {0:F} | Wednesday, June 15, 2016 2:55:22 PM | |
Month Name and Day | {0:M} | June 15 | |
Month Name and Year | {0:Y} | June, 2016 | |
Date and Time, sortable | {0:s} | 2016-06-15T14:55:22 | Date and time can be accurately sorted as text. |
Coordinated Universal Time (UTC) | {0:u} | 2016-06-15 14:55:22Z | |
RFC 1123 Format | {0:r} | Wed, 15 Jun 2016 14:55:22 GMT |
The following are component codes that can be combined to form a custom date format within the {0:Codes} notation. Components can be divided by spaces, slashes, colons, commas, or periods.
For example, the {0:MMM dd, yyyy} format will produce Feb 01, 2017.
All examples below are from the source date "2016-06-15T14:55:22.12-04:00".
Format | Code | Example |
Notes |
Year (short) | yy | 16 | A single "y" can be used to show the year as either 2-digits or 1-digit without any preceding zero, but will only work when other component codes are included. |
Year (long) | yyyy | 2016 | |
Month (number) | MM | 06 | A single "M" can be used to show the month as either 2-digits or 1-digit without any preceding zero, but will only work when other component codes are included. |
Month (short name) | MMM | Jun | |
Month (long name) | MMMM | June | |
Day (number) | dd | 15 | A single "d" can be used to show the day as either 2-digits or 1-digit without any preceding zero, but will only work when other component codes are included. |
Day (short name) | ddd | Wed | |
Day (long name) | dddd | Wednesday | |
Hour | hh | 02 | A single "h" can be used to show the hour as either 2-digits or 1-digit without any preceding zero, but will only work when other component codes are included. |
Hour (24 hour) | HH | 14 | A single "H" can be used to show the hour as either 2-digits or 1-digit without any preceding zero, but will only work when other component codes are included. |
AM/PM | tt | PM | |
Minutes | mm | 55 | A single "m" can be used to show the minutes as either 2-digits or 1-digit without any preceding zero, but will only work when other component codes are included. |
Seconds | ss | 22 | A single "s" can be used to show the seconds as either 2-digits or 1-digit without any preceding zero, but will only work when other component codes are included. |
Milliseconds (with trailing zeros) | fff | 120 |
Up to seven fs can be used to show the necessary precision, with trailing zeros if the source date does not have that many digits. A single "f" can be used to show just the first digit, but will only work when other component codes are included. |
Milliseconds (without trailing zeros) | FFF | 12 |
Up to seven Fs can be used to show the necessary precision, without trailing zeros if the source date does not have that many digits. A single "F" can be used to show just the first digit, but will only work when other component codes are included. |