Autor Beitrag
pepsen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Do 19.10.06 08:22 
tach...

also, ich würde ganz gern ein decodiertes Datum in ein Stringgrid schreiben. Allerdings muss es doch ein String sein und da wird mir dann aber ein encodiertes Datum in die Zelle geschrieben! Wie kann ich es denn als String übergeben und trotzdem in ganz normaler Form eines Datums behalten?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 19.10.06 11:48 
Moin!

user profile iconpepsen hat folgendes geschrieben:
ich würde ganz gern ein decodiertes Datum in ein Stringgrid schreiben.

:gruebel: Kannst du mal ein Beispiel machen... ? ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
oldmax
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 380


D3 Prof, D4 Prof
BeitragVerfasst: Do 19.10.06 11:50 
Tach auch..
Also, du willst eine Variable vom Typ TDate in ein Stringformat packen, so wie
ausblenden Delphi-Quelltext
1:
MyStringDatum:=FormatdateTime('dd.mm.yyyy',Date);					

aber auch sagen können:

ausblenden Delphi-Quelltext
1:
Date:=Now;					


Ein Grid ist nun mal nur eine Tabelle, die Strings beinhalten kann. Willst du mit dem Inhalt der Strings wieder eine Variable vom Typ TDate setzen, mußt du
ausblenden Delphi-Quelltext
1:
Date:=StringToDate(MyStringDatum);					

benutzen.....
Und dein MyStringDatum paßt natürlich in dein Stringgrid. Somit kannst du auch direkt ohne Verwendung von MyStringDatum die Stringgridfelder benutzen
Gruß oldmax

_________________
Zier dich nich so, ich krieg dich schon....
pepsen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Do 19.10.06 13:08 
ah, ich habs jetzt...Fehler lag wo anders -.-
mir war nich kla, dass sich hinter TDateTime ein Float verbirgt...ich hab es als Integer angenommen! Gelöst hab ich es jetzt so:

ausblenden Delphi-Quelltext
1:
2:
3:
dat1:= StrToFloat(query1.fieldbyname('F1').asstring) - 693594;
DecodeDate(Dat1, year, month, day);
stringgrid1.cells[0,i] := datetimetoStr(dat1);
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Do 19.10.06 16:34 
ausblenden Delphi-Quelltext
1:
2:
3:
dat1:= StrToFloat(query1.fieldbyname('F1').asstring) - 693594;
DecodeDate(Dat1, year, month, day);
stringgrid1.cells[0,i] := datetimetoStr(dat1);

Was soll das -693594 in Deinem Quellcode und warum die Funktion DecodeDate wenn Du die Parameter year, month, day danach nicht benutzt?

_________________
Ein Nutzer der Ecke ;-)
pepsen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Fr 20.10.06 07:16 
user profile iconMartin1966 hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
dat1:= StrToFloat(query1.fieldbyname('F1').asstring) - 693594;
DecodeDate(Dat1, year, month, day);
stringgrid1.cells[0,i] := datetimetoStr(dat1);

Was soll das -693594 in Deinem Quellcode und warum die Funktion DecodeDate wenn Du die Parameter year, month, day danach nicht benutzt?


@ 693594:
Das steht in der Hilfe: In Delphi 1.0 wurde das Datum vom Jahr 1 und nicht von 1899 an errechnet. Um ein Delphi 1.0-Datum in einen TDateTime-Wert einer neueren Delphi-Version zu konvertieren, subtrahieren Sie vom Delphi 1.0-Datum den Wert 693594,0.

@DecodeDate: Dies hab ich dem entnommen: www.dsdt.info/referenz/vcl_fcl/datum.php