Date format does not display correctly until the app is closed and opened

I am working on a simple database application in Delphi using FireDAC and SQLite3. Whenever I insert a new record into the database, the date format that is displayed on my form is always in the format yyyy-mm-dd

, and as soon as I close and reopen the application, the format changes to m/d/yyyy

which is the format I expected and want always show up without closing and reopening my app.

The parameters and definition parameters for the FireDAC connection are by default. The DataType for the field containing the date in the SQLite3 database is set to DATE

. Finally, the code I am using to insert the post is below.

Qry.SQL.Text := 'INSERT INTO employees (HireDate) VALUES (:HiredOn)';

Qry.ParamByName('HiredOn').AsDate := DateTimePicker1.Date;
Qry.ExecSQL;
Qry.Open('SELECT * FROM employees');  

      

Any help would be appreciated.

+3
date formatting delphi sqlite3 firedac


source to share


5 answers


Make sure any format settings for the date field in the underlying BindingSource / List / Adapter match the settings for the form / grid field. Perhaps the basic anchor formatting for the field is overriding your new settings for the form field / grid.



+1


source to share


Set the format / display to form field "m / d / yyyy" and for a good score , * also execute it with code in your event handlerInitializeGrid



+1


source to share


This happens with b / c when the date format in the form field does not match the date format in SQLite3, which is "yyyy-mm-dd". So you will need to set the format / display on the form field to match.

0


source to share


Uses DateUtils ...

DateUtils.DateOf (DateTimePicker1.Date);

0


source to share


Try

FormatDateTime ('dd / mm / yyyy', DateTimePicker1.Date);

0


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics