Re:Newbie: a Date with MSSQL 6.5
To set the value of a field in an open query, use this....
FieldByName('MyDateField').AsDateTime := encodeDate(1998, 01, 31);
The values for the encodeDate routine could be plucked by Delphi, from your
string using StrToDate, and setting your global date format string
accordingly.
When running a query, you can specify a date as a criteria like this.....
with Query1 do
begin
SQL.Lines.Add('Select * from MyTable Where');
SQL.Lines.Add('StartDate = :ddate');
ParamByName('ddate').AsDateTime := encodeDate(1998, 01, 31);
try
Open;
<do some stuff>
finally
Close;
end;
end;
Hope this helps.
Paul Chapman
Quote
Nicola Farina wrote in message <369B1F21.5F54...@tin.it>...
>Hi
>I am unable to insert a date with BDE 5.0 in a MSSQL 6,5 database
>in a DATETIME field.
>The machine is NT 4.0 sp3 Server
>With Database Desktop I have tried all the possible format (h.m.s d/m/y
>or
>m/d/y) I always got the error "Failed conversion from string to
>Datetime"
>May anyone give me some tips?
>Many thanks!
>Nicola
>--
>I.T. LOGISTICA S.r.L.
>via VIII Marzo 57 43044 Collecchio (PR) ITALY