@DATEFMT[date,format] - Formats a date/time in a custom format.

 

date - The date to format (in yyyy-mm-dd hh:mm:ss format). If date is *, @DATEFMT defaults to the current date/time. Valid dates are January 1, 1970 (1970-1-1) to December 31, 3000 (3000-12-31). The time must be in 24-hour format.

 

format - The custom format to use. (Note that the %'s will normally need to be doubled or escaped to prevent TCC-RT from expanding them before @DATEFMT sees them.) The formatting options are:

 

Code

Replacement string

%a

Abbreviated weekday name in the locale

%A

Full weekday name in the locale

%b

Abbreviated month name in the locale

%B

Full month name in the locale

%c

Date and time representation in the "C Locale" - equivalent to "%a %b %e %T %Y"

%C

The year divided by 100 and truncated to an integer, as a decimal number (00−99)

%d

Day of month as a decimal number (01 - 31)

%D

Equivalent to %m/%d/%y

%e

Day of month as a decimal number (1 - 31), where single digits are preceded by a space

%F

Equivalent to %Y-%m-%d

%g

The last 2 digits of the ISO 8601 week-based year (00 - 99)

%G

The ISO 8601 week-based year as a decimal number

%h

Abbreviated month name (equivalent to %b)

%H

Hour in 24-hour format (00 - 23)

%I

Hour in 12-hour format (01 - 12)

%j

Day of the year as a decimal number (001 - 366)

%m

Month as a decimal number (01 - 12)

%M

Minute as a decimal number (00 - 59)

%n

A newline character (\n)

%p

The locale's A.M./P.M. indicator for 12-hour clock

%r

The locale's 12-hour clock time

%R

Equivalent to %H:%M

%S

Second as a decimal number (00 - 59)

%t

A horizontal tab character (\t)

%T

Equivalent to %H:%M:%S, the ISO 8601 time format

%u

ISO 8601 weekday as a decimal number (1 - 7; Monday is 1)

%U

Week number of the year as a decimal number (00 - 53), where the first Sunday is the first day of week 1

%V

ISO 8601 week number as a decimal number (00 - 53)

%w

Weekday as a decimal number (0 - 6; Sunday is 0)

%W

Week number of the year as a decimal number (00 - 53), where the first Monday is the first day of week 1

%x

Date representation for the locale

%X

Time representation for the locale

%y

Year without century, as decimal number (00 - 99)

%Y

Year with century, as decimal number

%z

The offset from UTC in ISO 8601 format; no characters if time zone is unknown

%Z

Either the locale's time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown

%%

Percent sign

 

Characters that do not begin with a % are displayed unchanged.

 

The # flag may prefix any formatting code. In that case, the meaning of the format code is changed as follows:

 

Format code

Meaning

%#a, %#A, %#b, %#B, %#g, %#G, %#h, %#n, %#p, %#t, %#u, %#w, %#X, %#z, %#Z, %#%

# flag is ignored.

%#c

Long date and time representation, appropriate for the locale. For example: "Tuesday, February 25, 2020, 12:41:29".

%#x

Long date representation, appropriate to the locale. For example: "Tuesday, February 25, 2020".

%#d, %#D, %#e, %#F, %#H, %#I, %#j, %#m, %#M, %#r, %#R, %#S, %#T, %#U, %#V, %#W, %#y, %#Y

Remove leading zeros or spaces (if any).

 

The ISO 8601 week and week-based year produced by %V, %g, and %G, uses a week that begins on Monday, where week 1 is the week that contains January 4th, which is the first week that includes at least four days of the year. If the first Monday of the year is the 2nd, 3rd, or 4th, the preceding days are part of the last week of the preceding year. For those days, %V is replaced by 53, and both %g and %G are replaced by the digits of the preceding year.