[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'sysutils' (#rtl)

# TryStrToDate

Try to convert a string with a date indication to a TDateTime value

## Declaration

Source position: datih.inc line 163

`function TryStrToDate(`
`const S: ShortString;`
`out Value: TDateTime`
`):Boolean; function TryStrToDate(`
`const S: AnsiString;`
`out Value: TDateTime`
`):Boolean; function TryStrToDate(`
`const S: ShortString;`
`out Value: TDateTime;`
`separator: Char`
`):Boolean; function TryStrToDate(`
`const S: AnsiString;`
`out Value: TDateTime;`
`separator: Char`
`):Boolean; function TryStrToDate(`
`const S: ShortString;`
`out Value: TDateTime;`
`const useformat: string;`
`separator: Char = #0`
`):Boolean; function TryStrToDate(`
`const S: AnsiString;`
`out Value: TDateTime;`
`const useformat: string;`
`separator: Char = #0`
`):Boolean; function TryStrToDate(`
`const S: string;`
`out Value: TDateTime;`
`const FormatSettings: TFormatSettings`
`):Boolean;`

## Description

TryStrToDate tries to convert the string S to a TDateTime date value, and stores the date in Value. The Date must consist of 1 to three digits, separated by the DateSeparator character. If two numbers are given, they are supposed to form the day and month of the current year. If only one number is given, it is supposed to represent the day of the current month. (This is not supported in Delphi)

The order of the digits (y/m/d, m/d/y, d/m/y) is determined from the ShortDateFormat variable.

The function returns True if the string contained a valid date indication, False otherwise.

## See also

StrToDate |  | Convert a date string to a TDateTime value.
StrToTime |  | Convert a time string to a TDateTime value.
TryStrToTime |  | Try to convert a string with a time indication to a TDateTime value
TryStrToDateTime |  | Try to convert a string with date/time indication to a TDateTime value
DateToStr |  | Converts a TDateTime value to a date string with a predefined format.
TimeToStr |  | Convert a TDateTime time to a string using a predefined format.