Spectre Format Conventions
Many Spectre functions include options to indicate the format for input data or the format for output data. Certain syntactic conventions apply.
Dates and Periods
AAA |
Abbreviated day of the week |
Sun |
AAAA |
Day of the week |
Sunday |
D |
One or two digit days in a standard calendar |
4
|
D |
Weekday number in an ISO calendar |
2015-W53-5 |
DD |
Two digit day |
09 |
GM |
Gregorian one or two digit month—same as M, but forces the use of the standard calendar for non-standard period types |
2 |
GMM |
Gregorian two digit month—same as MM, but forces the use of the standard calendar |
03 |
GMMM |
Gregorian month abbreviation—same as MMM, but forces the use of the standard calendar |
Jul |
GYY |
Gregorian two digit year—same as YY, but forces the use of the standard calendar |
19 |
GYYYY |
Gregorian four digit year—same as YYYY, but forces the use of the standard calendar |
2019 |
M |
One or two digit month |
2 |
MM |
Two digit month |
03 |
MMM |
Month abbreviation |
Oct |
MMMM |
Month name |
October |
Q |
Quarter number |
2 |
W
|
Week number |
4 |
YYYY |
Four digit year |
2017 |
NOTE: If you want to include letters in the input or output date string, you must put a backslash ("\") in front of the characters. For example, "YYYY-\MMM-DD" parses "2020-M07-20".
Time
H |
One or two digit hours |
3 |
HH |
Two digit hours |
13 |
M |
One or two digit minutes |
6 |
MM |
Two digit minutes |
45 |
S |
One or two digit seconds |
3 |
SS |
Two digit seconds |
1 |
Datetime
Starting with version 7.0(43), Spectre has a new syntax for datetime parsing and formatting. Now, the datetime syntax uses the following format ("MM/DD/YYYY hh:mm:ss") similar to the date syntax. The earlier %-style formatting ("%m/%d/%Y %H:%M:%S") is supported, but is deprecated. Use of the new style is recommended. Spectre automatically detects which style is used and prints a warning for Build scripts that use the earlier style.
A datetime format string is a sequence of tokens, spaces and literal characters. Tokens are CASE-SENSITIVE. This is unlike date format strings, where for instance you can use either "yyyy" or "YYYY". This requirement is necessary to avoid ambiguous tokens (for example, does M mean month or minute) and introducing additional tokens.
Date tokens
Y |
Year, full |
2018 |
YY |
Year, 2 digits |
18 |
YYYY |
Year, full |
2018 |
H |
Half year (1 or 2) |
1 |
T |
Tertile (1-3) |
1 |
Q |
Quarter (1-4) |
2 |
M |
Month, 1 or 2 digits |
1 |
MM |
Month, zero padded to 2 digits |
01 |
MMM |
Month, 3-letter abbreviation |
Jan |
MMMM |
Month, full name |
January |
MMMMM |
Month, 1-letter abbreviation (cannot be used for parsing) |
J |
D |
Day of month, 1 or 2 digits |
3 |
DD |
Day of month, zero-padded to 2 digits |
03 |
AAA |
Day of week, 3-letter abbreviation |
Mon |
AAAA |
Day of week, full name |
Monday |
AAAAA |
Day of week, 1-letter abbreviation (cannot be used for parsing) |
M |
NOTE: The modifier G can be placed in front of the Y or M, similar to the date format (for example, GYYYY-GMM). The purpose of that modifier is to force the use of the standard calendar for non-standard period types. Because datetimes do not use non-standard calendars, the modifier has no effect, but it is allowed.
Time tokens
h |
Hour (0-23), 1 or 2 digits |
3 |
hh |
Hour (0-23), zero-padded to 2 digits |
15 |
i |
Hour (1-12), 1 or 2 digits |
3 |
ii |
Hour (1-12), zero-padded to 2 digits |
01 |
m |
Minute (0-59), 1 or 2 digits |
6 |
mm |
Minute (0-59), zero-padded to 2 digits |
08 |
s |
Second (0-59), 1 or 2 digits |
3 |
ss |
Second (0-59), zero-padded to 2 digits |
59 |
p |
AM/PM marker ('A' or 'P'), 1 letter |
A |
pp |
AM/PM marker ('AM' or 'PM'), 2 letters |
PM |
u |
Milliseconds |
|
NOTE:
- When parsing, a space matches any number of spaces in the input string.
- If you want to include letters in the input or output datetime string, you must put a backslash ("\") in front of the characters. For example, "YYYY-\MMM-DD hh:mm:ss" parses "2020-M07-20 15:07:00".
- If you put the format string in a Build script or cPlan calc, use double backslashes for letters (or in some cases quadruple backslashes).
- In addition to letters, other symbols that need backslashes are the left brace ("{') and the backslash itself.
- Other symbols, for example ":", "-", and "/", are treated as literals and do not need backslashes.
Numbers
format ="#,#"
format ="#,##0"
|
Round any decimal portion to present as whole number |
|
format ="#,##0.00" |
Round and present with 2 decimal places |
|
format="0,000.00" |
Present as minimum 4 whole digits and round to 2 decimal digits
|
|
format = "$#,##0.00" |
Include a dollar sign and 2 decimal places |
|
format="$#,#;\"$\"(#,#)" |
Present positive number with leading dollar sign; present negative number with leading dollar sign and parentheses—accounting format |
|
format="$#,#.00;\"$\"(#,#.00)" |
Present positive number with leading dollar sign and cents; present negative number with leading dollar sign, cents, and parentheses—accounting format |
|
format = "$#,###.00;-$#,###.00" |
Present positive number with leading dollar sign and cents; present negative number with leading dollar sign and cents |
|
format = "#%" |
Multiply by 100, round to whole number, and display with percent sign |
|
format = "#0.00\"%\"" |
Present the number with 2 decimal places and a percent sign |
|
format = "$#,#k" |
Present the number with the letter k and a dollar sign. |
|
format = "$#,#,k" |
Present the number as multiples of a thousand using a dollar sign. |
|
- By default, Diver assigns a numeric of 2 decimal places to numeric cBase fields. If the formatting is set to None, the ProDiver output matches any Spectre formatting defined by the Build script or cPlan.
- The inclusion of thousands separators in Spectre output depends on the use of a locale that supports it, for example, en_US.
Booleans
format="True;False" |
Indicates the format is the default for Boolean data: True or False.
|
format="T;F" |
Indicates the data presentation is T or F. |
format="Yes;No" |
Indicates the data presentation is Yes or No. |
format="true" |
Indicates the data presentation is true or blank for false. |
NOTE:
- In Spectre builds, format sets both the display and input properties, unless a separate input-format is specified.
- If the format has a blank after the semicolon, or if there is no semicolon, then blank values are considered false. Otherwise, when there is a semicolon and the string after it is not empty, blank values are parsed as null.