DateTime.TryParse

Syntax

TryParse(Value: String; Var Result: DateTime): Boolean;

Parameters

Value. The string that must be converted into the DateTime format.

Result. The date converted from the string.

Description

The TryParse method converts a string into the DateTime type with validation.

Comments

If conversion is successful, the method returns True, and the new value is placed into the variable specified in the Result parameter. If the conversion failed, the method returns False. The specified value must correspond to the available range that is set for the DateTime data type. If the date that is less than the available one is specified, the date, to which the current century is added, is automatically formed.

Example

Sub Main;

Var

d: DateTime;

b: Boolean;

Begin

b := DateTime.TryParse("01.01.02", D);

End Sub Main;

If after executing the example the "b" variable contains True, the conversion is successful, and the "d" variable contains the date "01.01.02".

See also:

DateTime