Date/Time Formatting

You can format tokens to automatically convert dates and times entered into them into specified formats. A standard format string is a single letter that represents a format that your data will automatically be converted to. A custom format string is a group of symbols that indicate the exact format for the information. Standard format strings are just shortcuts for frequently used formats that could also be achieved with custom format strings. You can type these specifiers directly in the tokens or use the token editor to insert the specifier and test the formatted token.

Standard Date and Time Format Strings

Standard date and format strings can be inserted into workflow tokens to format the values to match patterns determined by the regional settings of the computer where the Workflow Server is installed. View the regional settings in the control panel of the Workflow Server computer to determine how these strings will format your tokens.

Example: To format regional settings, Sally uses "%(DateTime#"g"#)". When tested with "January 23, 2018, 0:00", she receives "1/23/2018 12:00 AM" (English - United States) or "23/01/2018 00:00" (French - France).

Standard Date and Time Strings
Specifier Type Function
d Short date pattern Formats to short date pattern defined by user's regional settings (e.g., "1/2/2017".)
D Long date pattern Formats to long date pattern defined by user's regional settings (e.g. "Monday, January 02, 2017".)
t Short time pattern Formats to hours and minutes defined by user's regional settings (e.g. "12:01 PM".)
T Long time pattern Formats to hours, minutes, and seconds defined by user's regional settings (e.g. "12:01:02 PM").
f Full date/time pattern (short time) Formats as long date (D) and short time (t) (e.g. "Monday, January 02, 2017 12:01 PM").
F Full date/time pattern (long time) Formats as long date (D) and long time (T) (e.g. "Monday, January 02, 2017 12:01:02 PM").
g General date/time pattern (short time) Formats as short date (d) and short time (t) (e.g. "1/2/2017 12:01 PM").
G General date/time pattern (long time) Formats as short date (d) and long time (T) (e.g. "1/2/2017 12:01:02 PM").
M Month day pattern Formats month and day defined by user's regional settings (e.g. "1/2/2017 12:01:02 PM").
Y or y Year month pattern Formats year and month defined by user's regional settings (e.g. "January, 2017").
u Universal sortable pattern Formats pattern with a four-digit year, then 2-digit for the rest. (e.g. "2017-01-02 12:01:02Z").

To learn more about standard date and time formatting, see the Microsoft Developers' Network (MSDN) site.

Custom Date and Time Format Strings

You can also create custom strings to format dates and times to any combination of date and time formats. A popular use for this is to use dates extracted from your documents to create document names or folder paths according to a standardized system.

Example: Sally wants to organize her documents into folders labeled with the last two digits of the year and the abbreviation for the month. She formats a token that contains the date accordingly and uses the Rename Entry activity to name her folders. Sally uses "%(Date#"yy-MMM"#)". When tested with "January 23, 2018", she receives "18-Jan" (English-United States) or "18-jan" (Portuguese-Brazil).

Custom Date and Time Strings
Specifier Type Function
/ Date separator Differentiates years, months, and days.
: Time separator Differentiates hours, minutes, and seconds.
" or ' Quoted string indicator Represents the literal value between quotes.
% Single custom format specifier indicator Interprets the value between quotes literally.
\ Escape character Represents the literal value after the backslash (\).
d Day: 1-31 Represents a day from 1 to 31 (e.g., "%d" returns "2").
dd Day: 01-31 Represents a day from 01 to 31 (e.g., "%dd" returns "02").
ddd Abbreviated day of the week Represents an abbreviated weekday (e.g., "%ddd" returns "Mon").
dddd (etc.) Full day of the week Represents a weekday (e.g., "%dddd" returns "Monday").
M Month: 1-12 Represents a month from 1 to 12 (e.g., "%M" returns "1").
MM Month: 01-12 Represents a month from 01 to 12 (e.g., "%MM" returns "01").
MMM Abbreviated month Represents an abbreviated month (e.g., "%MMM" returns "Jan").
MMMM Full month Represents a month (e.g., "%MMMM" returns "January").
y Year: 1-2 digits Represents the year to a one or two-digit number (e.g., "%y" returns "17").
yy Year: 2 digits Represents the year to a two-digit number (e.g., "%yy" returns "17").
yyy Year: 3 or more digits Represents the year to a three-or-more-digit number (e.g., "%yyy" returns "017").
yyyy Year: 4 digits Represents the year to a four-digit number (e.g., "%yyyy" returns "2017").
yyyyy (etc.) Year: 5 or more digits Represents the year to a five-digit number (e.g., "%yyyyy" returns "02017").
g, gg, etc. Era Represents the era, which is ignored if the era is not specified (e.g., "g" returns "AD").
h Hour: 1-12 Represents an hour from 1 to 12 (e.g., "%h" returns "1").
hh Hour: 01-12 Represents an hour from 01 to 12 (e.g., "%hh" returns "01").
H Hour: 0-23 Represents an hour from 0 to 23 (e.g., "%H" returns "1").
HH Hour: 00-23 Represents an hour from 00 to 23 (e.g., "%HH" returns "01").
m Minutes: 0-59 Represents a minute from 0 to 59 (e.g., "%m" returns "1").
mm Minutes: 00-59 Represents a minute from 00 to 59 (e.g., "%mm" returns "01").
s Seconds: 0-59 Represents a second from 0 to 59 (e.g., "%s" returns "1").
ss Seconds: 00-59 Represents a second from 00 to 59 (e.g., "%ss" returns "01").
f, ff, etc. or F, FF, etc. Fractions of a second Each "f" and "F" represent a digit in milliseconds (e.g., "%ff" returns "01").
t First character of AM/PM designator Represents the time period in the day as a single letter (e.g., "t" returns "P").
tt AM/PM designator Represents the time period as two letters (e.g., "tt" returns "PM").

To learn more about custom date and time formatting, see the Microsoft Developers' Network (MSDN) site.