| Autor |
Beitrag |
huuuuuh
      
Beiträge: 665
Erhaltene Danke: 19
win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
|
Verfasst: Fr 14.03.08 16:17
Quelltext 1: 2: 3:
| jahrak:= strtoint(copy (edit2.text,7,10)); monatak:=strtoint( copy (edit2.Text,4,5)); tagak:= strtoint(copy (edit2.Text,1,2)); |
ich will ein datum in jahr, monat, tag zerlegen (edit2 enthält das datum)
es funktioniert aber nich...kann mir jemand helfen?
zB.
12.03.2008
felermeldung
'03.20' is not a valid integer value
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Fr 14.03.08 16:19
Moin und  im Forum!
Gib mal DecodeDate ein und drück F1.
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
huuuuuh 
      
Beiträge: 665
Erhaltene Danke: 19
win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
|
Verfasst: Fr 14.03.08 16:36
Returns Year, Month, and Day values for a TDateTime value.
Unit
SysUtils
Category
datetime routines
Delphi syntax:
procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
C++ syntax:
extern PACKAGE void __fastcall DecodeDate(const System::TDateTime DateTime, Word &Year, Word &Month, Word &Day);
Description
The DecodeDate procedure breaks the value specified as the Date parameter into Year, Month, and Day values. If the given TDateTime value has a negative (BC) year, the year, month, and day return parameters are all set to zero.
aus der delphi hilfe
aber wie soll ich das jetz anwenden? habs versucht....und bin gescheitert
|
|
icho2099
      
Beiträge: 101
Erhaltene Danke: 12
WIN XP, WIN 7, WIN 10
Delphi 6 Prof, Delphi 2005, FPC
|
Verfasst: Fr 14.03.08 16:53
machs so:
richtig zählen, dann klappts auch mit dem Nachbarn....
Delphi-Quelltext 1: 2: 3:
| jahrak:= strtoint(copy (edit2.text,7,4)); monatak:=strtoint( copy (edit2.Text,4,2)); tagak:= strtoint(copy (edit2.Text,1,2)); |
oder so:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
| Uses DateUtils;
Var DT : TDatetime; Year, Month, Day : Integer;
begin DT := StrToDate(Edit1.Text); Year := YearOf(Dt); Month := MonthOf(Dt); Day := DayOf(Dt);
DecodeDate(DT,Year,Month,Day); end; |
|
|
Marc.
      
Beiträge: 1876
Erhaltene Danke: 129
Win 8.1, Xubuntu 15.10
|
Verfasst: Fr 14.03.08 16:59
Hi!
Du solltest dich eventuell ersteinmal mit den Grundlagen auseinander setzen.
So beinhalten Var-Parameter (Var steht für variable -> übergeben via Referenz) im Grunde nichts anderes als die Speicheradressen deiner übergeben Variablen. Alle Zugriffe und Änderungen innerhalb der Prozedur beziehen sich folglich direkt auf diese.
Delphi-Quelltext 1:
| procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word); |
Nun sollte auch klar sein, wie die Prozedur zu verwenden ist.
Cheers,
Marc
|
|
huuuuuh 
      
Beiträge: 665
Erhaltene Danke: 19
win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
|
Verfasst: Fr 14.03.08 17:04
muss ich mir die copy funktion nochma angucken...tatsächlich falsch gezählt...
dankeschön
|
|
huuuuuh 
      
Beiträge: 665
Erhaltene Danke: 19
win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
|
Verfasst: Fr 14.03.08 17:05
@marc: weiss ich alles...habs aber trotzdem nich hingekriegt...
|
|
Marc.
      
Beiträge: 1876
Erhaltene Danke: 129
Win 8.1, Xubuntu 15.10
|
Verfasst: Fr 14.03.08 17:08
huuuuuh hat folgendes geschrieben: | | @marc: weiss ich alles...habs aber trotzdem nich hingekriegt... |
Wie das?! In meiner Doh ist sogar noch ein Beispiel dabei.  Aber Hauptsache, du hast es nun verstanden.
|
|
|