Date and Time Format Specifiers

Applies to TestComplete 15.68, last modified on October 16, 2024

This topic describes format specifiers that you can use in the aqConvert.DateTimeToFormatStr function. This function converts date and time values to strings, its FormatStr parameter determines the exact contents of the resulting string. FormatStr is a string that can contain any symbolic characters and a number of special characters prefixed by the % symbol. The latter characters are called format specifiers. Ordinary characters are copied from FormatStr to the resulting string without any changes, whereas format specifiers are replaced with the respective date or time elements.

The following format specifiers are available:

Specifier Description
%a Abbreviated weekday name.
%A Full weekday name.
%b Abbreviated month name.
%B Full month name.
%c Date and time representation appropriate for locale. If the # flag (%#c) precedes the specifier, long date and time representation is used.
%d Day of month as a decimal number (01 – 31). If the # flag (%#d) precedes the specifier, the leading zeros are removed from the number.
%H Hour in 24-hour format (00 – 23). If the # flag (%#H) precedes the specifier, the leading zeros are removed from the number.
%I Hour in 12-hour format (01 – 12). If the # flag (%#I) precedes the specifier, the leading zeros are removed from the number.
%j Day of year as decimal number (001 – 366). If the # flag (%#j) precedes the specifier, the leading zeros are removed from the number.
%m Month as decimal number (01 – 12). If the # flag (%#m) precedes the specifier, the leading zeros are removed from the number.
%M Minute as decimal number (00 – 59). If the # flag (%#M) precedes the specifier, the leading zeros are removed from the number.
%p Current locale's A.M./P.M. indicator for 12-hour clock.
%S Second as decimal number (00 – 59). If the # flag (%#S) precedes the specifier, the leading zeros are removed from the number.
%U Week of year as decimal number, with Sunday as first day of week (00 – 53). If the # flag (%#U) precedes the specifier, the leading zeros are removed from the number.
%w Weekday as decimal number (0 – 6; Sunday is 0). If the # flag (%#w) precedes the specifier, the leading zeros are removed from the number.
%W Week of year as decimal number, with Monday as first day of week (00 – 53). If the # flag (%#W) precedes the specifier, the leading zeros are removed from the number.
%x Date representation for current locale. If the # flag (%#x) precedes the specifier, long date representation is enabled.
%X Time representation for current locale.
%y Year without century, as decimal number (00 – 99). If the # flag (%#y) precedes the specifier, the leading zeros are removed from the number.
%Y Year with century, as decimal number. If the # flag (%#Y) precedes the specifier, the leading zeros are removed from the number.
%z, %Z Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown.
%% Percent sign.

See Also

DateTimeToFormatStr Method
Working With Dates
Working With Time

Highlight search results