Autor Beitrag
flowstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 123

WinME
D6 Enterprise
BeitragVerfasst: Di 18.11.03 23:36 
Die Überschrift sagt eigentlich schon alles. Ich will in einer DBCtrlGrid nur Datensätze anzeigen, die in der Datumsspalte einen bestimmten Monat haben. Wie mache ich das?
Wenn jetzt was mir SQL kommt erklärt es bitte genau hab keine Ahnung davon.
eternity
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mi 19.11.03 01:33 
Keine Ahnung was ein DBCtrlGrid ist.

Ich mach es so.

SQL.Text:='SELECT [*] FROM "[DB]" WHERE [Monat]=[wert]';


[ ]=Optional


cu
flowstar Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 123

WinME
D6 Enterprise
BeitragVerfasst: Mi 19.11.03 16:44 
Danke erstmal
Ich will aber beim Programmstart immer wieder überprüfen welcher Monat gerade ist. Ich hab ihn schon als Variable im Programm aber wie kann ich ihn in die SQL Anweisung einbauen?
infomio
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 110

Win xy

BeitragVerfasst: Mi 19.11.03 17:08 
ich weiß nicht welche Datenbank du benutzt, aber das Grid muß ja auf eine Datenbank zugreifen - oder, also gibt es wahrscheinlich eine SQL-Anweisung dafür.

Oft ist das datum im Datumsformat (date oder datetime) vorhanden.
Um den Monat herauszufiltern gibt es die Möglichkeit im SQL zu fragen:

select blablabla
from Tabelle

where month(Datumsfeld) = :Monat
and year(Datumsfeld) = :laufendesJahr (nicht vergessen!!! :-))

order by blablabla


(z.B. MicrosoftSQLServer)

Die Syntax ist abhängig von der Datenbank und wird leider nicht von jeder unterstützt