You can format a date and/or time in a predefined format or in a format that you define.
Contents [Hide] |
The formats featured in this topic only apply to these GainSeeker modules:
Dynamic Reports
The formats for SPC Data Entry, DMS Data Entry, SPC Charts and Reports, DMS Charts and Reports, and Enterprise Dashboard modules are likely to differ from those featured in this topic. See Date/Time formats for information that applies to these GainSeeker modules.
The table below identifies the predefined (standard) date/time format names. Only those commonly used with GainSeeker are featured. See Examples below. For information on other formatting options, see the Microsoft .Net Framework documentation.
Format Specifier |
Format Name |
Description |
d |
Short date pattern |
Display a date according to the short date format in the workstation's regional options. For example, "MM/dd/yyyy." |
D |
Long date pattern |
Display a date according to the long date format in the workstation's regional options. For example, "dddd, dd MMMM yyyy." |
f |
Full date/time pattern (short time) |
Display a combination of the long date (D) and short time (t) patterns, separated by a space. |
F |
Full date/time pattern (long time) |
Display a date and time according to the long date format in the workstation's regional options. For example, |
g |
General Date/time pattern (short time) |
Display a combination of the short date (d) and short time (t) patterns, separated by a space. |
G |
General Date/time pattern (long time) |
Display a combination of the short date (d) and Long time (T) patterns, separated by a space. |
M or m |
Month day pattern |
Display a custom DateTime format string defined by the month and day property set in the workstation. |
The table below identifies characters you can use to create user-defined (custom) date/time formats. Only those commonly used with GainSeeker are featured. See Examples below. For information on other formatting options, see the Microsoft .Net Framework documentation.
Character |
Description |
: |
Time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by the time separator in a workstation's regional options. |
/ |
Date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by the date separator in the workstation's regional options. |
" |
Display the literal value of any string between two quotation marks ("). Precede each quotation mark with an escape charter (\). |
' |
Display the literal value of any string between two. |
%c |
Display the custom format specifier c preceded by a (%) to indicate that specifier is the only component of a string. To use "d," "f," "F" . . . , specify "%d," "%f," "%F" . . . . |
\c |
display the character "c" as a literal when that character is preceded by the escape character (\). Use two escape characters (\\) to insert the backslash character itself in the result string. |
Any other character |
Any other character is copied to the result string and does not affect formatting. |
d |
Display the day as a number without a zero preceding single digits (1–31). |
dd |
Display the day as a number with a zero preceding single digits (01–31). |
ddd |
Display the day as an abbreviation (Sun–Sat). |
dddd |
Display the day as a full name (Sunday–Saturday). |
f |
Display the most significant digit of the seconds fraction. (For each "f" character added, one additional significant digit will display. For example, for ffff, the four most significant digits of the seconds fraction will display. |
F |
Display the most significant digit of the seconds fraction; nothing is displayed if the digit is zero. (For each "F" character added, one additional significant digit will display. For example, for FFFF, the four most significant digits of the seconds fraction will display. Trailing zeros do not display.) |
g or gg |
Display the period or era (A.D., for example) except when the date to be formatted excludes an associated period or era string. |
h |
Use the twelve-hour clock and display the hour as a number without a zero preceding single-digit hours (1–12). The time "5:43" would display "5." |
hh |
Use the twelve-hour clock and display the hour as a number with a zero preceding single-digit hours (01–12). The time "5:43" would display "05." |
H |
Use a zero-based twenty-four-hour clock and display the hour as a number without a zero preceding single-digit hours (0–23). |
HH |
Use a zero-based twenty-four-hour clock and display the hour as a number with a zero preceding single-digit hours (0–23). |
K |
Display different values of the DateTime.Kind property such as "Local," "Utc," or "Unspecified." Local: equivalent to the zzz specifier, displaying the local offset from GMT; UTC: Display a "Z" character to represent a UTC date; Unspecified: equivalent to "" (nothing). |
m |
Display the minute as a number without a zero preceding single-digit minutes (1–59). |
mm |
Display the minute as a number with a zero preceding single-digit minutes (01–59). |
M |
Display the month as a number without a zero preceding single-digit months(1–12). |
MM |
Display the month as a number with a zero preceding single-digit months (01–12). |
MMM |
Display the month as an abbreviation (Jan–Dec). |
MMMM |
Display the month as a full name (January–December). |
s |
Display the second as a number without a zero preceding single-digit seconds (0–59). |
ss |
Display the second as a number with a zero preceding single-digit seconds (00–59). |
t |
Displays the first character of the A.M. or P.M. designator. |
tt |
Display the A.M. or P.M. designator. |
y |
Display the day of the year as a two-digit number without a zero preceding single-digit years (1–99). |
yy |
Display the year as a two-digit number with a zero preceding single-digit years (01–99). |
yyy |
Display the year as a three-digit number with zeros preceding single-digit years (001–999). |
yyyy |
Display the year as a four-digit number with zeros preceding single-digit years (0001–2099). |
yyyyy |
Display the year as a five-digit number with zeros preceding single-digit years (00001–02099). |
z |
Display the time zone offset of a workstation from the Greenwich Mean Time (GMT) in hours without a zero preceding single-digit hours (-12 to +13). The offset is always preceded by a minus sign (-) to indicate hours behind GMT, or a plus sign (+) to indicate the hours before GMT. |
zz |
Display the time zone offset of a workstation from the Greenwich Mean Time (GMT) in hours with a zero preceding single-digit hours (-12 to +13). The offset is always preceded by a minus sign (-) to indicate hours behind GMT, or a plus sign (+) to indicate the hours before GMT. |
zzz |
Display the time zone offset of a workstation from the Greenwich Mean Time (GMT) in hours and minutes with a zero preceding single-digit hours or minutes (-12:00 to +13:00). The offset is always preceded by a minus sign (-) to indicate hours/minutes behind GMT, or a plus sign (+) to indicate the hours/minutes before GMT. |
Format string |
Output when regional options are |
d |
10/23/2024 |
F |
Tuesday, October 23, 2024 11:26:59 AM |
M/d/yy |
10/23/24 |
d-MMM |
23-Oct |
d-MMMM-yy |
23-October-24 |
d MMMM |
23 October |
MMMM yyyy |
October 2024 |
hh:m tt |
11:26 AM |
h:mm:ss t |
11:26:17 A |
h:mm |
11:26 |
h:m:ss |
11:26:45 |
M/d/yy h:mm |
10/23/2024 11:26 |