Error in field date

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
knancys
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 07.11.2005, 14:18
Location: Ribeirao PReto/SP
Contact:

Error in field date

Post 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
silviogs
Junior Boarder
Junior Boarder
Posts: 42
Joined: 24.08.2005, 12:54
Location: The Most Oriental Point of America - João Pessoa - Brazil
Contact:

Post by silviogs »

Hi

use:

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

do not mix apples and oranges:

DateTime is not TDate.

Respectfully

Silvio Guedes
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post 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
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
Post Reply