Link to home
Start Free TrialLog in
Avatar of marioway
marioway

asked on

Date problem in Firebird

Hi, I have a problem using dates in Firebird.
       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;;

Open in new window

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
Avatar of Nick Upson
Nick Upson
Flag of United Kingdom of Great Britain and Northern Ireland image

firebird doesn't like the format of the date string, is FACTUURDATUM a timestamp my any chance
Avatar of marioway
marioway

ASKER

No , Date

       with Distinctfactuurklantidquery 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 .....
Sorry, I see now that I made an error

ParamByName('pKLANTID').AsDate:= Temp1query1.FieldByName('KLANTID').AsInteger;

Should be:   ParamByName('pKLANTID').AsInteger:= Temp1query1.FieldByName('KLANTID').AsInteger;;
if you replace the variables with hard-coded values does it work then, try several different formats and dates and post the results
Nick, it works now, I coded: ParamByName('pKLANTID').AsDate, should be: ASINTEGER

Mario
SOLUTION
Avatar of Nick Upson
Nick Upson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial