Thursday, August 27, 2009

Firebird date fields

In continuation of my previous post about problems of inserting/update date fields in FB databases, I did a little poking around and eventually - by trial and error - found the correct syntax:
update data
set datefield = '01/01/2008'
where id = 1;

It's going to be an interesting exercise producing code like that from Delphi, as the single quotation mark is the string delimiter, and it's always fun trying to create strings which include the quote. It'll have to be something like this:
with sqlquery.sql do
begin
add ('update data');
add ('set datefield = ''' + query1.fieldbyname ('datefield').asstring + ''' where id = 1';
end;

Let us not forget that the date is being passed from a query which is accessing the original BDE database.

1 comment:

Rommel said...

Its best to use parameters instead of concatenating the parameter value to the SQL string. And if you are forced to concatenate, use QuotedString.