Uživatelsky definované formáty

General syntax

A user-defined format is described by a sequence of special characters.

Arbitrary characters specified before and after the format strings will be printed as is.

Format syntax for a numeric expression

+ Prints the sign of the number.
- Prints the sign of the number only if it is negative.
# Prints a digit only if necessary.

The number is left-padded with spaces so that the number of printed characters before the decimal point is greater or equal than the number of # before the decimal point.
0 Always prints a digit, padding with a zero if necessary.
. Prints the decimal separator.
, Prints the thousand separators.
% Multiplies the number by 100 and prints a per-cent sign.
E Introduces the exponential part of a Float number. The sign of the exponent is always printed.

Examples

PRINT Format$(Pi, "-#.###")
3.142

PRINT Format$(Pi, "+0#.###0")
+03.1416

PRINT Format$(Pi / 10, "###.# %")
31.4 %

PRINT Format$(-11 ^ 11, "#.##E##")
-2.85E+11

Format syntax for currencies

To format currencies, you can use all numeric format characters, and the following ones:

$ Prints the national currency symbol.
$$ When the $ is doubled, the international currency symbol is printed instead.
( Prints the representation of negative currencies. This must be the first character of the format. You can specify a closed brace ) at the end of the format.

Examples

PRINT Format$(1972.06, "$#.###")
$1972.06

PRINT Format$(-1972.06, "$,#.###")
-$1,972.06

PRINT Format$(-1972.06, "($$,#.###)")
(USD 1,972.06)

Format syntax for dates

yy Prints the year on two digits.
yyyy Prints the year on four digits.
m Prints the month.
mm Prints the month on two digits.
mmm Prints the month in an abbreviatted localized string form.
mmmm Prints the month in its full localized string form.
d Prints the day.
dd Prints the day on two digits.
ddd Prints the week day in an abbreviated localized form.
dddd Prints the week day in its full localized form.
/ Prints the date separator.
h Prints the hour.
hh Prints the hour on two digits.
n Prints the minutes.
nn Prints the minutes on two digits.
s Prints the seconds.
ss Prints the seconds on two digits.
: Prints the time separator.
u Prints a point and the milliseconds, if they are different from zero.
uu Prints a point and the milliseconds with three digits.
AM/PM Prints the localized equivalent of AM or PM, according to the hour, and force the hour to be between 1 and 12.

The u date format does not print a point anymore. You must add it explicitly in the format string.

Examples

PRINT Format$(Now, "mm/dd/yyyy hh:nn:ss.u")
04/15/2002 09:05:36.26

PRINT Format$(Now, "mm/dd/yyyy hh:nn:ss.uu")
04/15/2002 09:05:36.026

PRINT Format$(Now, "m/d/yy h:n:s")
4/15/02 9:5:36

PRINT Format$(Now, "ddd dd mmm yyyy")
Mon 15 Apr 2002

PRINT Format$(Now, "dddd dd mmmm yyyy")
Monday 15 April 2002

PRINT Format$(Now, "yyyy-mm-dd hh-nn-ss")
PRINT Format$(Now, "yyyy/mm/dd hh:nn:ss")
2006-04-29 07-41-11
2006.04.29 07:41:11