Subject Re: Date format using Delphi and Firebird
Author Adam
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
>
> At 02:34 PM 12/11/2005 +0200, you wrote:
> >Hi,
> >
> >
> >
> >What must I make sure of before inserting a record with a date
field into a
> >Firebird 1.5 table? I get the EConvertError error 'is not a valid
date',
> >using Delphi 7. The field is declared as a Date field in the table.
I assign
> >the field a value as follows -
> >
> > qryGen.ParamByName('workdate').Value := strtodate('2005/11/12
02:00:19
> >PM');

One extra thing.

StrToDate function relies on the local PCs regional settings short
date format to decide whether to use dd/mm/yyyy or mm/dd/yyyy. So
don't use it to format dates (personally I think it should be removed
from Delphi).

You can use encodedate to convert a day month and year into a date,
and this is multi-region safe. But as Helen said, use the .Date or
.DateTime property on pretty much any date picker-ish looking
component, it saves you a lot of coding and is less likely to
introduce a bug.

Adam