![]() |
Re: StrToDate
Zerlege den String und erzeuge daraus das Datum
|
Re: StrToDate
|
Re: StrToDate
Zitat:
|
Re: StrToDate
Hallo,
das Prinzip bleibt das gleiche:
Delphi-Quellcode:
Grüße vom marabu
function StrToDate(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) + AnsiIndexText(sMonth, ShortMonthNames); Str(nMonth:2, sMonth); s := StuffString(s, iMonth, 3, sMonth); end; Result := SysUtils.StrToDate(s); end; |
Re: StrToDate
Zitat:
|
Re: StrToDate
@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; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:32 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz