Page 1 of 1

Error in field date

Posted: 13.02.2006, 14:53
by knancys
My table it consists a field "DATACADASTRO TIMESTAMP NOT NULL"
In the Lazarus when inserting a register I use following code:

Code: Select all

 TQuery.FieldByName('DATACADASTRO').AsDateTime := Date; 
But when I load it the register (select * from table), to return an error because of the date that was saved.

Example: 14-02-06 (dd/mm/aa) saved as 0000-12-31 95:18:55.4336 and in the error it returns the date 0-12-31

How to decide this?


---
Database Firebird 1.5 / OS Linux / Lazarus 0.9.10

Posted: 14.02.2006, 14:41
by silviogs
Hi

use:

TQuery.FieldByName('DATACADASTRO').AsDateTime := now;

do not mix apples and oranges:

DateTime is not TDate.

Respectfully

Silvio Guedes

Posted: 15.02.2006, 16:58
by gto
silviogs wrote:Hi
use:
TQuery.FieldByName('DATACADASTRO').AsDateTime := now;
do not mix apples and oranges:
DateTime is not TDate.
Respectfully
Silvio Guedes
Yes, I think here's the problem, too
by the way, you can use
TQuery.FieldByName('DATACADASTRO').AsString := FormatDateTime('dd/mm/yyyy',now());

or

TQuery.FieldByName('DATACADASTRO').AsDate := Date

The last one I don't be certain if works, but look's like yes.

[]'s