Autor Beitrag
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Fr 14.03.08 16:17 
ausblenden 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
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 14.03.08 16:19 
Moin und :welcome: im Forum!

Gib mal DecodeDate ein und drück F1. :think: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: 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
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 101
Erhaltene Danke: 12

WIN XP, WIN 7, WIN 10
Delphi 6 Prof, Delphi 2005, FPC
BeitragVerfasst: Fr 14.03.08 16:53 
machs so:

richtig zählen, dann klappts auch mit dem Nachbarn....

ausblenden 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:

ausblenden 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
  (* String in TDatetime *)
  DT := StrToDate(Edit1.Text);
  (* zerlegen *)
  Year := YearOf(Dt);
  Month := MonthOf(Dt);
  Day := DayOf(Dt);

  (* oder so zerlegen *)
  DecodeDate(DT,Year,Month,Day);
end;
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: 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.
ausblenden 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 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Fr 14.03.08 17:04 
muss ich mir die copy funktion nochma angucken...tatsächlich falsch gezählt...

dankeschön
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Fr 14.03.08 17:05 
@marc: weiss ich alles...habs aber trotzdem nich hingekriegt...
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Fr 14.03.08 17:08 
user profile iconhuuuuuh hat folgendes geschrieben:
@marc: weiss ich alles...habs aber trotzdem nich hingekriegt...

Wie das?! In meiner Doh ist sogar noch ein Beispiel dabei. :o Aber Hauptsache, du hast es nun verstanden.