Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 02.09.07 20:11 
Hi, Delpher,

ich möchte gern die folgende Unterscheidung loswerden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.heuteGeburtstag1Click(Sender: TObject);
begin        
  QSchueler.close;                        //"Schueler.dbf"
  QSchueler.DatabaseName  := listbox8.Items[listbox8.itemindex];
  if QSchueler.DatabaseName = '' then
  begin
    QSchueler.sql.text := format('select Name, Vorname, Klasse, Gebdat, Telefon from "%s" ' +
                                 ' where GEBDAT LIKE :DATUM order by Klasse', [TbSchueler.tablename]);
      QSchueler.ParamByName('DATUM').asstring := maskedit1.editText+'%'
  end
  else
  begin
    QSchueler.sql.text := format('select Name, Vorname, Klasse, Gebdat, Telefon from "%s" ' +
                                 ' where GEBDAT = :DATUM order by Klasse', [TbSchueler.tablename]);
      QSchueler.ParamByName('DATUM').asdate := date;
  end;
  QSchueler.open;


Wer hat dazu eine Idee?

Grüße von
Detlef Annies
Michael Stenzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 133


D3 Prof, D7 PE
BeitragVerfasst: So 02.09.07 22:15 
Hi D.Annies.

Ich weiß ja nicht , was Du vor hast. Vieleicht meinst Du es ja so.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.heuteGeburtstag1Click(Sender: TObject);
begin
  QSchueler.close;                        //"Schueler.dbf"
  QSchueler.DatabaseName  := listbox8.Items[listbox8.itemindex];
  if QSchueler.DatabaseName = '' then
  begin
       maskedit1.editText := DateToStr(Date);
  end;
  QSchueler.sql.text := format('select Name, Vorname, Klasse, Gebdat, Telefon from "%s" ' +
                               ' where GEBDAT LIKE :DATUM order by Klasse', [TbSchueler.tablename]);
  QSchueler.ParamByName('DATUM').asstring := maskedit1.editText+'%'
  QSchueler.open;
end;


Wenn Dir der Datumsaustausch über dem Editfeld nicht zusagt, kannst Du es ja mal mit einer String - Variablen versuchen.

Gruß
Michael
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 03.09.07 06:47 
Hi, Michael,

in der einen DBTabelle ist das Datum als String gespeichert, also zB 05.12.1992 in der anderen Tabelle als echtes Date, also zB 19920804. Im maskedit steht nur zB 03.11. ohne Jahresangabe.

Am besten wäre es wohl, wenn ich immer ein echtes Datum habe in beiden Tabellen, das kann ich zB mit der BDE auch umkonvertieren.

Aber wie kann ich dann unter Zuhilfenahme des maskedit in beiden Fällen den Geburtsatg (ohne Jahr) sicher erkennen?

Ich hoffe, ich habe es jetzt klarer ausgedrückt. :roll:

Danke für weitere Hilfe,
Detlef
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 03.09.07 07:41 
In dem du nur Tag und Monat vergleichst.

_________________
Markus Kinzler.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 03.09.07 08:51 
Hallo, Markus,

und wie geht das? Das ist genau das Problem!!
Ich weiß es nicht.

Viele Grüße, Detlef
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 04.09.07 06:10 
Hi, Markus et aliter,

ich habe jetzt einen Tag abgewartet auf weitere Antworten und ich war auch nicht untätig, aber eine Lösung habe ich nicht gefunden, nur einen Hinweis auf Cast, bei dem ich aber eine Fehlermeldung bekomme:

ausblenden Delphi-Quelltext
1:
2:
...where Cast(GEBDAT as string) and GEBDAT Like :Datum;
Parambyname('Datum').asstring := maskedit1.edittext +'%';


Wer hat noch eine Idee?

Gruß, Detlef
Andreas Schilling
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128
Erhaltene Danke: 1

WIN XP, WIN 7
Delphi 5 Ent, Delphi 2007 Pro, XE4
BeitragVerfasst: Di 04.09.07 07:13 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
QSchueler.sql.text := format('select Name, Vorname, Klasse, Gebdat, Telefon from "%s" ' +  
                                 ' where EXTRACT (MONTH FROM GEBDAT)=:MONAT and EXTRACT (DAY FROM GEBDAT)=:TAG ' +
                                 'order by Klasse', [TbSchueler.tablename]);  
QSchueler.ParamByName('Monat').asstring := copy(maskedit1.editText, 4,2); 
QSchueler.ParamByName('Tag').asstring := copy(maskedit1.editText, 1,2);

Extract Month und day liefern Smallinteger, eventuell Parameter nach Integer konvertieren.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 04.09.07 15:00 
Hi, Andreas,
danke für deine Antwort!
Mann, was habe ich damit experimentiert!!

Häufig bekam ich : Function is missing. Zur Zeit bin ich bei:

Command contains unrecognized phrase / keyword bei dem Befehl:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
    Mo := strtoint(copy(maskedit1.editText,4,2));
    Tg := strtoint(copy(maskedit1.editText,1,2));
    
    QSchueler.sql.text :=
      format('select Name, Vorname, Klasse, Telefon, Gebdat, ' +
             ' from "%s" ' +
             'where EXTRACT(MONTH FROM GEBDAT) = :MONAT ' +
             ' and EXTRACT(DAY FROM GEBDAT) = :TAG ' +
             'order by Klasse', [TbSchueler.tablename]);
    QSchueler.ParamByName('Monat').asinteger := Mo;
    QSchueler.ParamByName('Tag').asinteger := Tg;


Was ist denn daran noch falsch??

Grüße von Detlef
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 04.09.07 15:04 
Bei manchen DBMS geht es mit Month( GebDat)

_________________
Markus Kinzler.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 04.09.07 15:11 
Hallo, Markus - leider hier nicht, Fehler wie oben (Command..)

Trotzdem erstmal wieder Danke,

Detlef :autsch:
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 04.09.07 15:19 
Steig endlich auf ein richtiges DBMS um, da geht das.

_________________
Markus Kinzler.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Di 04.09.07 15:21 
nimm mal das Komme hinter GebDat raus.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
format('select Name, Vorname, Klasse, Telefon, Gebdat, <-- hier' +  
             ' from "%s" ' +  
             'where EXTRACT(MONTH FROM GEBDAT) = :MONAT ' +  
             ' and EXTRACT(DAY FROM GEBDAT) = :TAG ' +  
             'order by Klasse', [TbSchueler.tablename]);

_________________
Bravery calls my name in the sound of the wind in the night...
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 04.09.07 18:39 
Hi, noidic,

so was dummes!
Aber leider: Fehlermeldung: Extract.prg not found

Uups!

P.S. Ich denke, mit D7 arbeite ich mit einem mitgelieferten SQL!?

Was könnte denn noch gehen - aufgeben is ja nicht!

Gruß, Detlef
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 04.09.07 21:19 
Hi, Markus und alle anderen!!

So, nun klappt es!
Ich hatte gedacht, mkinzler meinte extract(month(gebdat)),
aber es war month(gebdat)

Herzlichen Dank nochmal an alle!!

Detlef