marioway
asked on
Date problem in Firebird
Hi, I have a problem using dates in Firebird.
"1899-12-31"
I tried tot use CAST, but the result is the same. What might be the problem here ?
thx
Mario
T1:= StrToDate(MaskEdit3.Text);
T2:= StrToDate(MaskEdit4.Text);
SQL.Text:= 'SELECT SUM(BEDRAGTOTAAL) AS SOM1 FROM KASSAVERKOPEN ' +
'WHERE ((FACTUURDATUM BETWEEN :pNu AND :pNi) ' +
'AND (KLANTID = :pKLANTID) AND (VOLDAAN = 1))';
ParamByName('pNu').AsDate:= T1;
ParamByName('pNi').AsDate:= T2;
ParamByName('pKLANTID').AsDate:= Temp1query1.FieldByName('KLANTID').AsInteger;;
I get an error when (FACTUURDATUM BETWEEN :pNu AND :pNi) --> conversion error -303"1899-12-31"
I tried tot use CAST, but the result is the same. What might be the problem here ?
thx
Mario
firebird doesn't like the format of the date string, is FACTUURDATUM a timestamp my any chance
ASKER
No , Date
with Distinctfactuurklantidquer y do begin
Close;
SQL.Text:= 'SELECT DISTINCT KLANTID FROM FACTUUR ' +
'WHERE ((VOLDAAN = 1) AND (FACTUURDATUM BETWEEN BETWEEN :pNu AND :pNi))';
ParamByName('pNu').AsDate: = T1;
ParamByName('pNi').AsDate: = T2;
Open;
First;
end;
this query for instance works fine; strange .....
with Distinctfactuurklantidquer
Close;
SQL.Text:= 'SELECT DISTINCT KLANTID FROM FACTUUR ' +
'WHERE ((VOLDAAN = 1) AND (FACTUURDATUM BETWEEN BETWEEN :pNu AND :pNi))';
ParamByName('pNu').AsDate:
ParamByName('pNi').AsDate:
Open;
First;
end;
this query for instance works fine; strange .....
ASKER
Sorry, I see now that I made an error
ParamByName('pKLANTID').As Date:= Temp1query1.FieldByName('K LANTID').A sInteger;
Should be: ParamByName('pKLANTID').As Integer:= Temp1query1.FieldByName('K LANTID').A sInteger;;
ParamByName('pKLANTID').As
Should be: ParamByName('pKLANTID').As
if you replace the variables with hard-coded values does it work then, try several different formats and dates and post the results
ASKER
Nick, it works now, I coded: ParamByName('pKLANTID').As Date, should be: ASINTEGER
Mario
Mario
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.