![]() |
String mit UTC in TDateTime
Hi,
ich bekomme aus einer XML - Datei z.B. folgenden String: 2013-01-07T12:51:21.456+01:00 Jetzt wollte ich daraus wie folgt ein DateTime machen:
Delphi-Quellcode:
Ich erhalte den Fehler, dass der string keine gültige Datums- / Zeitangabe ist.
function TCrefoXML.AsDateTime(ANode: IXMLNode): Variant;
Var s: string; AFormat: TFormatSettings; begin Result := Null; if (ANode <> nil) then begin s := ANode.Text; if s <> '' then begin AFormat.DateSeparator := '-'; AFormat.TimeSeparator := ':'; AFormat.ShortDateFormat := 'yyyy-mm-dd'; AFormat.LongDateFormat := 'yyyy-mm-dd'; AFormat.ShortTimeFormat := 'hh:mm'; AFormat.LongTimeFormat := 'hh:mm:ss'; Result := StrToDateTime(s, AFormat); end; end; end; Liegt das an dem 'T' hiner dem Datum? Was bedeudet das und was ist mein Fehler? Frank |
AW: String mit UTC in TDateTime
Hi
SELECT convert(varchar, getdate(), 126) – yyyy-mm-ddThh:mm:ss.mmm – 2008-10-02T10:52:47.513 gruss Peter |
AW: String mit UTC in TDateTime
Vielen Dank,
ich habe deine Version nicht getestet, da ich doch eine Lösung gefunden habe. XMLTimeToDateTime aus XSBuiltIns scheint das richtige Ergebnis zu liefern. Frank |
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:52 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