DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....


ScanDateTime

Declaration: ScanDateTime (InString, Format: string; Language: TLanguage; var error: integer): TDateTime;
The function ScanDateTime encodes a formatted date/time string into a TDateTime. The parameter Instring contains the date/time string to be scanned. The parameter Format specifies the format of the date/time string (see below). The parameter Language determines which language to use when scanning month and day names.

The variable parameter error returns the following error codes:

 0 ... no error
-1 ... literal string does not match Format mask
-2 ... Format string contains illegal character combination
-3 ... conversion failed due to invalid date/time specification

The following format characters can be used in the Format parameter (please note that the format characters are case sensitive):

Element Description
d The one- or two-digit day.
dd The two-digit day. Single-digit day values are preceded by a zero.
ddd The three-character weekday abbreviation.
dddd The full weekday name.
h The one- or two-digit hour in 12-hour format.
hh The two-digit hour in 12-hour format. Single-digit values are preceded by a zero.
H The one- or two-digit hour in 24-hour format.
HH The two-digit hour in 24-hour format. Single-digit values are preceded by a zero.
m The one- or two-digit minute.
mm The two-digit minute. Single-digit values are preceded by a zero.
M The one- or two-digit month number.
MM The two-digit month number. Single-digit values are preceded by a zero.
MMM The three-character month abbreviation.
MMMM The full month name.
s The one- or two-digit second.
ss The two-digit second. Single-digit values are preceded by a zero.
t The one-letter AM/PM abbreviation (that is, AM is displayed as "A").
tt The two-letter AM/PM abbreviation (that is, AM is displayed as "AM").
yy The last two digits of the year (that is, 2001 would be displayed as "01"). Please note that the global variable TwoDigitYearCenturyWindow (declared in Delphis "sysutil" unit) determines the range of years which are interpreted as years of the current century.
yyyy The full year (that is, 2001 would be displayed as "2001").

To include literal strings in the format, enclose them in single quotes. Failing to quote literal strings can have unpredictable results, even if they do not include formatting codes. Use two single quotes to represent one single quote character in literal string.

Hint: Please note the subtle differences between the format characters used in ScanDateTime and the date/time format strings used for FormatDateTime.