You can use format strings to specify date, time, timestamp, and number formats in imported documents.
To specify a date, time, or timestamp format string, use the following pattern letters:
Symbol |
Meaning |
Presentation |
Example |
G |
Era designator |
(Text) |
AD |
y |
Year |
(Number) |
1996 |
M |
Month in year |
(Text & Number) |
March & 03 |
d |
Day in month |
(Number) |
15 |
h |
Hour in AM/PM (1-12) |
(Number) |
12 |
H |
Hour in day (0-23) |
(Number) |
0 |
m |
Minute in hour |
(Number) |
30 |
s |
Second in minute |
(Number) |
55 |
S |
Millisecond |
(Number) |
978 |
E |
Day in week |
(Text) |
Tuesday |
D |
Day in year |
(Number) |
189 |
F |
Day of week in month |
(Number) |
2 (2nd Wed in July) |
w |
Week in year |
(Number) |
27 |
W |
Week in month |
(Number) |
2 |
a |
AM/PM marker |
(Text) |
PM |
k |
Hour in day (1-24) |
(Number) |
24 |
K |
Hour in AM/PM (0-11) |
(Number) |
0 |
z |
Time Zone |
(Text) |
Pacific Standard Time |
‘ |
Escape for text |
(Delimiter) |
|
‘ ‘ |
Single quote |
(Literal) |
‘ |
Any characters in the pattern other than letters A-Z will be treated as quoted text. For example, the format string "mm/dd/yy" might appear as "03/15/96".
For Text presentation characters, use fewer than 4 characters for the abbreviated form, and 4 or more characters for the full form. For example, the format string "dd MMM yyyy" might appear as "15 Mar 1996", while "MMMM dd yyyy" appears as "March 15 1996".
For Number presentation characters, the number of characters in the format string indicates the minimum number of digits to display. Shorter numbers are zero-padded to the minimum amount. For example, the format string "h:mm a" might appear as "6:30 PM", while "hh:mm a" appears as "06:30 PM".
To specify a number format string, use the following symbols:
Symbol |
Meaning |
0 |
A digit |
# |
A digit; zero shows as absent |
. |
Place holder for decimal separator |
, |
Place holder for grouping separator |
; |
Separates formats |
- |
Default negative prefix |
% |
Multiply by 100 and show as percentage |
‰ |
Multiply by 1000 and show as per mille |
¤ |
Currency sign; replaced by currency symbol. If doubled, replaced by international currency symbol. If present in a pattern, the monetary decimal separator is used instead of the decimal separator. |
X |
Any other characters can be used in the prefix or suffix |
‘ |
Used to quote special characters in a prefix or suffix |
Type number format strings using the following components:
Component |
Definition |
Pattern |
A pattern is a complete format string. If your column can contain both positive and negative values, then your pattern should consist of two sub patterns. The first sub pattern represents the format for positive numbers, and the second sub pattern represents the format for negative numbers. Place a ";" before the second sub pattern to separate the two. For example, you might type "#00.0# ;-##0.0#" as a format string. |
Sub pattern |
A sub pattern is a complete format string that is part of a pattern. Sub patterns represent either positive or negative number formats. Sub patterns may be made up of prefixes, integers, fractions, and suffixes, in that order. |
Prefix |
A prefix is a character or characters that appear before each number value in the column. You must indicate any prefixes in your number format string so that they are not processed as part of the value. Any characters other than numbers and decimal separators must be included in a prefix or suffix. For instance, in the sub pattern "$ ##0.0#", "$" is a prefix. |
Suffix |
A prefix is a character or characters that appear after each number value in the column. You must indicate any suffixes in your number format string so that they are not processed as part of the value. Any characters other than numbers and decimal separators must be included in a prefix or suffix. For instance, in the sub pattern "#0 yrs", "yrs" is a prefix. |
Integer |
An integer is composed of the digits in a number string before the decimal separator. Integer digits may be represented by "#" or "0". To indicate that the number of digits is not fixed, place an "*" after the digit symbol. |
Fraction |
A fraction is composed of the digits in a number string after the decimal separator, and is preceded by a "." For example, in the sub pattern "##0.0#", ".0#" is a fraction. |
You can also use the following forms of notation in a number format string:
Notation |
Meaning |
* |
Indicates 0 or more elements of the type immediately preceding (if after the decimal separator) or following (if before the decimal separator) the *. For example, in the format string "*#0.00", number values for the column may be of any length, with two fixed decimal places and at least one integer before the decimal separator. In the format string "00.0#*", number values for the column may have one or more decimal places, but must have exactly two integer digits. |
1* |
Indicates 1 or more elements of the type immediately preceding (if after the decimal separator) or following (if before the decimal separator) the 1*. For example, in the format string "1*#0.00", number values for the column may be of any length, with two fixed decimal places and at least two integers before the decimal separator. In the format string "00.0#1*", number values for the column may have 2 or more decimal places, but must have exactly two integer digits. |
| |
Indicates an either/or relationship. For example, in the format string "*#0 (apples|oranges|bananas)", the number in each value is followed by either "apples", "oranges", or "bananas". |
/ |
Indicates an either/or relationship. For example, in the format string "*#0 (apples/oranges/bananas)", the number in each value is followed by either "apples", "oranges", or "bananas". |
.. |
Indicates that the value may be any character from that preceding the .. to that following it, inclusive. For example, in the format string "1..8", the value for the column may be any number between 1 and 8. |
- |
Indicates that the value may be any character in the set preceding the -, except for those in the set following it. For example, in the format string "(1..12) - 7", the value for the column may be any number between 1 and 12, except 7. |
[] |
Indicates that the enclosed elements are optional. |
() |
Can be used to group elements. |
<> |
Indicates that the enclosed elements are a literal string. For example, if you want the character " to appear as part of your value, you must type it as <">. |