Format Context [Format FormatSpec]Text or Number[/Format]
Formats text or numbers in various widths or currency formats.

To display numbers with various decimal points or currency formats, surround the number or text with a [Format] context.

Example (normally you would put the following text into a .tpl file on your server and use a web browser to link to it):

[Format 10.2f]99.5[/Format] (f stands for floating-point number)
[Format 10s]Hello[/Format] (s stands for string of text)
[Format Days_To_Date %m/%d/%y]195462[/Format] (3.0)
[Format Seconds_To_Time]49768[/Format]
[Format Seconds_To_Time %I:%M:%S %p]49768[/Format]
[Format thousands 14.2f]394363210[/Format]
[Format thousands 14,2f]394363210[/Format]
[Format thousands .3d]7[/Format] (d stands for decimal number)

The number displays right-justified with enough preceding spaces and digits after the decimal point to fill the exact width of the format specifier. Text is left-justified, with enough spaces after it to exactly fill the width specifier.

|     99.50| (10 wide, 2 after the decimal)
|Hello     | (10 wide, text)
|01:49:28 PM| 
|04/07/1997| (#days as a date)
|394,363,201.00| (14 wide, number with thousands separator)
|394.363.201,00| (14 wide, number with European thousands separator)
|007| (3 wide, integer part of number only, zeroes preceding)

Given a number 345.67, the following format specifiers will display as shown:

8.3f = | 345.670| (f stands for floating point)
8.2f = |  345.67|
8.1f = |   345.7| (notice rounding from .67 to .7)
8.0f = |     346| (notice rounding from .67 to next higher integer)
 .5d = |00345| (notice no rounding, and preceding 0s to fill 5 digits)

Optional date format -- to format a number as a date (the number must represent the number of days since Midnight, January 1st, 0000), use the optional date specifier and a date format, the same as from the [date] tag. Also see date and time [Math].

User Contributed Notes

Copyright © 2008 WebDNA Software Corporation, Inc.