Autor Beitrag
Coolman1974
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Do 15.12.05 13:03 
Hallo zusammen,

ich habe das Problem, das mir die Umwandlung von DateTime in String nicht gelingen will.

Ich bekomme über eine WMI-Abfrage '20051215113543.973428+060' als DateTime-Typ geliefert.

Doch bei DateTimeToStr('20051215113543.973428+060) giebt es einen Fehler (ungültige Gleitkommaoperation).

Hat jemand eine Ahnung wie ich mit diesem Format umgehen muss?

Moderiert von user profile iconTino: Titel erweitert.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 15.12.05 13:10 
Was du bekommst ist nicht vom Typ TDateTime:
20051215113543 = 2005 12 15 und noch irgendwas
Die Nachkommastellen habe ich mir jetzt nicht angesehen.
TDateTime ist ein Gleitkommatyp. Dort wird die Zeit ab einem Zeitpunkt angegeben. Dort steht kein Datum im Klartext drin.

Daher kann auch deine Umwandlung nicht funktionieren. Einen kleinen Ansatz habe ich dir ja schon gegeben.
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Do 15.12.05 13:10 
Dassieht nicht aus wie ein TDateTime. TDateTime ist die Anzahl der Tage seit dem 30.12.1899 - was du da hast, sieht aus wie eine Zahl, die sich einfach direkt aus Datum und Uhrzeit zusammengesetzt ist. Wäre 15.12.2005 11:35:43 plausibel? Dann musst du die Zahl selbst zerlegen - sollte ja nicht so schwierig sein.

Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
Coolman1974 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Do 15.12.05 13:16 
Ja, das ist ja schon klar.

Der Typ den ich bekomme ist aber definitiv DateTime.

Schau mal hier "CreationDate" msdn.microsoft.com/l...mi/win32_process.asp

Hier wird es als DateTime deklariert.


????
Coolman1974 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Do 15.12.05 13:20 
Aber was bedeutet dann "973428+060" ???
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Do 15.12.05 13:37 

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 15.12.05 13:41 
Das Format DateTime vom MS hat nichts mit dem von Delphi zu tun. Dort heißt es ja auch TDateTime. :wink:
Coolman1974 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Do 15.12.05 13:53 
OK, alles klar !!!

Habs nun so gelöst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
aTemp := quProzess.FieldByName('CreationDate');

aDate := copy(aTemp, 14);
aDate := aDate + '.' + copy(aTemp, 52);
aDate := aDate + '.' + copy(aTemp, 72);

aTime := copy(aTemp, 92);
aTime := aTime + ':' + copy(aTemp, 112);
aTime := aTime + ':' + copy(aTemp, 132);

aDateTime := aDate + ' - ' + aTime;



Danke an alle !!!

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.