Autor Beitrag
areuter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75



BeitragVerfasst: Mo 16.10.06 15:25 
Hallo ich habe eine Frage bezüglich einer Datumsformatierung.
In einer DB (Paradox7) habe ich ein Datumfeld. Jetzt möchte ich das Datum vergleichen..was mache ich falsch?

Zitat:
if (table4.locate('Datum',monthcalendar1.Date,[]=false)) then


fehler: inkompatible typen
oder hättet ihr eine andere idee?
vielen Dank arne
uwewo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Mo 16.10.06 15:40 
Verscuhs mal hiermit, ohne Gewähr

ausblenden Delphi-Quelltext
1:
if (table4.locate(StrToDate(Datum),monthcalendar1.Date,[]=false)) then					
areuter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75



BeitragVerfasst: Mo 16.10.06 15:48 
nein leider auch nicht..
uwewo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Mo 16.10.06 15:58 
Ok, habs mir nochmal geanuer angesehen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
        LocateSuccess      : Boolean;
    SearchOptions      : TLocateOptions;
begin
SearchOptions := [loCaseInsensitive];
//1. Möglichkeit
LocateSuccess := table4.locate('Datum',monthcalendar1.Date,SearchOptions);
2. Möglichkeit
//LocateSuccess := table4.locate('Datum',DateToStr(monthcalendar1.Date),SearchOptions);

if LocateSuccess then //irgendwas
areuter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75



BeitragVerfasst: Mo 16.10.06 16:25 
die sache mit dem datetostr ist das problem.
in der db ist ein datenfeld als typ: date hinterlegt.
wenn der rechner sich jetzt das datum aus dem monthcalendar holt, ist dies (wohl?) ein anderer datumstyp wie in der db? ich kann weder den monthcalendar mit datetostr noch das db-feld date in datetostr wandeln. obwohl beide bei der ausgabe das richtige datum anzeigen..
inkompatible typen..weshalb auch immer!
cyberax
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 247

Win XP Pro
Delphi 5 Enterprise
BeitragVerfasst: Mo 16.10.06 17:02 
Hallo,
hatte auch mal so ein Problem und habe mir zum Vegleich ein kleone Procedure geschrieben, die das Format umwandelt. Kann aber nicht sagen, ob das bei Paradox so passt.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
function datum_wandeln(datum:tdate):string;
var d,m,y:string;
begin
 d:=datetostr(datum);
 m:=datetostr(datum);
 y:=datetostr(datum);
 delete(d, 3,8);
 delete(m, 1,3);
 delete(m, 3,5);
 delete(y,1 ,6);
 datum_wandeln:=y+'-'+m+'-'+d;
end;


Wenn du zum Beispiel
ausblenden Delphi-Quelltext
1:
 edit1.text:=datum_wandeln(monthcalendar1.date);					

machst müsste das Format 2006-10-16 spricht -> Jahr - Monat - Tag sein.
areuter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75



BeitragVerfasst: Mo 16.10.06 21:57 
gibt es für mein problem keine schöne lösung?
die kleine routine nutzt nichts, wenn man z.b ein table1.findkey oder table1.locate durchführen möchte..??
bin ratlos!
grüsse arne
raiguen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 374

WIN 2000prof, WIN XP prof
D7EP, MSSQL, ABSDB
BeitragVerfasst: Mo 16.10.06 22:36 
Moin Arne :-)

Tut mich ja traurig, aber ich konnte Dein Problem nicht nachvollziehen :-( Hab mir mal 'ne alte ParadoxTabelle geangelt und dort diverse Datumsfelder (Typ TDate) über den MonthCalendar gejagt -> das Locate hat alles gefunden. Fehlermeldung(en) beim Compilieren hab ich auch nicht bekommen...
Ähm...nur mal so als (dumme) Frage: Fehlermeldung exact in der Zeile mit dem Locate ??? Wie gesagt: bei mir funzt es...

Gruß