Date$

 

Purpose:

Converts a date, using a format string, into an appropriately formatted string.

Composition of the format string: this is a normal string into which placeholders can be embedded.

Place holder

Description

%d

Day (1..31)

%<n>d

Day to <n> digits

%0<n>d

Day to <n> digits, filled on left with '0's

%w

Weekday (1..7)

%<n>w

Weekday to <n> digits

%0<n>w

Weekday to <n> digits, filled on left with '0's

%W

Week of year

%<n>W

Week of year to <n> digits

%0<n>W

Week of year to <n> digits, filled on left with '0's

%m

Month (1..12)

%<n>m

Month to <n> digits

%0<n>m

Month to <n> digits, filled on left with '0's

%y

Year

%<n>y

Year, to <n> digits

%0<n>y

Year, to <n> digits, filled on left with '0's

%q

Quarter

%D

Weekday, written out

%M

Month, written out

"%e", "%<n>e"

Year in the local calendar (Japan: Emperor's year)

"%g", "%<n>g"

Era of the local calendar (Japan: Emperor’s era)

"%g", "%1g"

Single letter, Latin letters

"%gg", "%2g"

Single letter, localized

"%ggg", "%3g"

Long name, localized

"%gggg", "%4g"

Long name, Latin letters

"%x"

Localized date, short form

%H

Hours in 24h-format

%h

Hours in 12h-format

%<n>h

Hours in <n> digits

%i

Minutes

%<n>i

Minutes in <n> digits

%s

Seconds

%<n>s

Seconds in <n> digits

%PM

AM or PM

As long as one of the above formats is used, the optional third parameter can be used to set the locale. If the second parameter contains a valid ISO 3166-Country code, the third parameter can be used to set either the short "0” or long "1” format.

Parameter:

Date               Value to be formatted.

String         (optional) Format description or ISO 3166-Country code.

String         (optional) ISO 3166-Country code or date format.

Return value:

String

Example:

Date$(Today(),"%D, %d/%m/%y")   Result: Thursday, 8/11/2015

Date$(Today(),"%2WthWeek; %D, %2d/%2m/%4y")       Result: 45th Week, Thursday, 8/11/2015

Date$(Today(),"%D, %3d/%02m/%4y")      Result: Thursday,  8/11/2015

Date$ (Now(),"%02h:%02i:%02s %PM")     Result: 04:03:50 PM