@marabu. Danke! Das funktioniert endlich.
Verwende die Funktion nun so:
Delphi-Quellcode:
function StrToDateTime(s: string): TDateTime;
var
iMonth, nMonth: Integer;
sMonth: string;
begin
iMonth := Pos('mmm', ShortDateFormat);
if iMonth > 0 then
begin
sMonth := Copy(s, iMonth, 3);
nMonth := Low(ShortMonthNames) + StrUtils.AnsiIndexText(sMonth, ShortMonthNames);
Str(nMonth:2, sMonth);
s := StuffString(s, iMonth, 3, sMonth);
end;
Result := SysUtils.StrToDateTime(s);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
DateStr: string;
dtDateTime: TDateTime;
Begin
DateStr := '23-Mai-2008 17:01';
DateSeparator := '-';
TimeSeparator := ':';
ShortDateFormat := 'dd.mmm.yyyy';
dtDateTime := StrToDateTime(DateStr);
end;