Hi,
If you don't want to use parameters, you could also use something like
the following:
var
Year, Month, Day: word;
Year := StrToInt(FormatDateTime('yyyy', Now));
Month := StrToInt(FormatDateTime('mm', Now));
Day := StrToInt(FormatDateTime('dd', Now));
SQL.Add('insert into expense (exp_dt)');
SQL.Add('values (' + QuotedStr(FormatDateTime('dd-mmm-yyyy',
EncodeDate(Year, Month, Day))) + ')');
Of course you can replace Year, Month, Day with your own DateTime value.
:-)
________________________________
From: [email protected] [mailto:[email protected]] On
Behalf Of Marselle
Sent: Friday, 28 August 2009 12:41 PM
To: [email protected]
Subject: Re: [delphi-en] Sql insert date problem
have you tried to set up the field types that you are passing as
Parmameters.
I would suggest creating properties or local variables of that you want
to use, cast the type of the data passing in to the correct datatype of
the insert using something like
ltDate : Date Time if the field type is a Date Field
or if the field is a string type
I would do :stDate := sql component name ParamByName('exp_dt').asString
don't hard code the values.
--- On Thu, 8/27/09, tony_bat <[email protected]
<mailto:tony_bat%40yahoo.com> > wrote:
> From: tony_bat <[email protected] <mailto:tony_bat%40yahoo.com> >
> Subject: [delphi-en] Sql insert date problem
> To: [email protected] <mailto:delphi-en%40yahoogroups.com>
> Date: Thursday, August 27, 2009, 3:56 PM
> I retrieve data from paradox table
> then construct sql statement for insertion into firebird
> table.
>
> 'insert into expense
> ( exp_seq, description, amount, type, exp_dt,
> invoice_no, miles, obsolete )
> values
> (1,'Transfer Tape
> ','17.8','1',"8/27/2009",'737198-00',0,'False')'
>
> If I use double qoute around date I get unknown column
> error. If I use single quote around date I get arithmetic
> exception, numeric overflow error.
>
> using firebird driver 2.00.00.144
>
> Tony
>
>
>
> ------------------------------------
>
> -----------------------------------------------------
> Home page: http://groups.yahoo.com/group/delphi-en/
<http://groups.yahoo.com/group/delphi-en/>
> To unsubscribe: [email protected]
<mailto:delphi-en-unsubscribe%40yahoogroups.comYahoo> !
> Groups Links
>
>
> mailto:[email protected]
<mailto:delphi-en-fullfeatured%40yahoogroups.com>
>
>
>
[Non-text portions of this message have been removed]