It is in System.Variants.VarToDateTime, it can change any possible string to datetime.

Converts a specified variant to a TDateTime value.

VarToDateTime converts the given variant to a TDateTime value. VarToDateTime raises an exception if the conversion fails.

procedure THRForm.Button1Click (Sender: TObject);
was
  D:TDateTime;
  s:string;
begin 
  D: = VarToDateTime ( " 05-10-14 4:35 PM " );
  S:=FormatDatetime('YYYY-MM-DD HH:MM:SS',D);
  showmessage(s);
end;

Especially when doing database statement operations, there are too many uncertain factors for the source of the string. It is really convenient to use this function. Examples are as follows:

Construct a new function SetFieldDate with VarToDateTime, and then use this function to assign values ​​to the database time field, just

FQuery.Parameters.ParamValues['Brithday'] := SetFieldDate(edit1.Text);
function SetFieldDate(str: string): Variant;
begin
if str = '' then
result := Null
else
result := StrToDateTime(FormatDatetime('YYYY-MM-DD', VarToDateTime(str)));
end;

Of course, the above functions can also be simplified as:

function SetFieldDate(str: string): Variant;
begin
  if str = '' then
    result := Null
  else
    result := VarToDateTime(str);
end;